
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>What’s New In Python 3.7 &#8212; Python 3.8.13 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
    
    <link rel="stylesheet" href="../_static/pydoctheme.css?2022.1" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../_static/language_data.js"></script>
    
    <script src="../_static/sidebar.js"></script>
    
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python 3.8.13 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="next" title="What’s New In Python 3.6" href="3.6.html" />
    <link rel="prev" title="What’s New In Python 3.8" href="3.8.html" />
    <link rel="canonical" href="https://docs.python.org/3/whatsnew/3.7.html" />
    
      
    

    
    <style>
      @media only screen {
        table.full-width-table {
            width: 100%;
        }
      }
    </style>
<link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
            <script type="text/javascript" src="../_static/copybutton.js"></script>
            <script type="text/javascript" src="../_static/menu.js"></script> 

  </head>
<body>
<div class="mobile-nav">
    <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
           aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
    <label for="menuToggler" class="toggler__label">
        <span></span>
    </label>
    <nav class="nav-content" role="navigation">
         <a href="https://www.python.org/" class="nav-logo">
             <img src="../_static/py.svg" alt="Logo"/>
         </a>
        <div class="version_switcher_placeholder"></div>
        <form role="search" class="search" action="../search.html" method="get">
            <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
                <path fill-rule="nonzero"
                        d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" fill="#444"></path>
            </svg>
            <input type="text" name="q" aria-label="Quick search"/>
            <input type="submit" value="Go"/>
        </form>
    </nav>
    <div class="menu-wrapper">
        <nav class="menu" role="navigation" aria-label="main navigation">
            <div class="language_switcher_placeholder"></div>
  <h3><a href="../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">What’s New In Python 3.7</a><ul>
<li><a class="reference internal" href="#summary-release-highlights">Summary – Release Highlights</a></li>
<li><a class="reference internal" href="#new-features">New Features</a><ul>
<li><a class="reference internal" href="#pep-563-postponed-evaluation-of-annotations">PEP 563: Postponed Evaluation of Annotations</a></li>
<li><a class="reference internal" href="#pep-538-legacy-c-locale-coercion">PEP 538: Legacy C Locale Coercion</a></li>
<li><a class="reference internal" href="#pep-540-forced-utf-8-runtime-mode">PEP 540: Forced UTF-8 Runtime Mode</a></li>
<li><a class="reference internal" href="#pep-553-built-in-breakpoint">PEP 553: Built-in <code class="docutils literal notranslate"><span class="pre">breakpoint()</span></code></a></li>
<li><a class="reference internal" href="#pep-539-new-c-api-for-thread-local-storage">PEP 539: New C API for Thread-Local Storage</a></li>
<li><a class="reference internal" href="#pep-562-customization-of-access-to-module-attributes">PEP 562: Customization of Access to Module Attributes</a></li>
<li><a class="reference internal" href="#pep-564-new-time-functions-with-nanosecond-resolution">PEP 564: New Time Functions With Nanosecond Resolution</a></li>
<li><a class="reference internal" href="#pep-565-show-deprecationwarning-in-main">PEP 565: Show DeprecationWarning in <code class="docutils literal notranslate"><span class="pre">__main__</span></code></a></li>
<li><a class="reference internal" href="#pep-560-core-support-for-typing-module-and-generic-types">PEP 560: Core Support for <code class="docutils literal notranslate"><span class="pre">typing</span></code> module and Generic Types</a></li>
<li><a class="reference internal" href="#pep-552-hash-based-pyc-files">PEP 552: Hash-based .pyc Files</a></li>
<li><a class="reference internal" href="#pep-545-python-documentation-translations">PEP 545: Python Documentation Translations</a></li>
<li><a class="reference internal" href="#development-runtime-mode-x-dev">Development Runtime Mode: -X dev</a></li>
</ul>
</li>
<li><a class="reference internal" href="#other-language-changes">Other Language Changes</a></li>
<li><a class="reference internal" href="#new-modules">New Modules</a><ul>
<li><a class="reference internal" href="#contextvars">contextvars</a></li>
<li><a class="reference internal" href="#dataclasses">dataclasses</a></li>
<li><a class="reference internal" href="#importlib-resources">importlib.resources</a></li>
</ul>
</li>
<li><a class="reference internal" href="#improved-modules">Improved Modules</a><ul>
<li><a class="reference internal" href="#argparse">argparse</a></li>
<li><a class="reference internal" href="#asyncio">asyncio</a></li>
<li><a class="reference internal" href="#binascii">binascii</a></li>
<li><a class="reference internal" href="#calendar">calendar</a></li>
<li><a class="reference internal" href="#collections">collections</a></li>
<li><a class="reference internal" href="#compileall">compileall</a></li>
<li><a class="reference internal" href="#concurrent-futures">concurrent.futures</a></li>
<li><a class="reference internal" href="#contextlib">contextlib</a></li>
<li><a class="reference internal" href="#cprofile">cProfile</a></li>
<li><a class="reference internal" href="#crypt">crypt</a></li>
<li><a class="reference internal" href="#datetime">datetime</a></li>
<li><a class="reference internal" href="#dbm">dbm</a></li>
<li><a class="reference internal" href="#decimal">decimal</a></li>
<li><a class="reference internal" href="#dis">dis</a></li>
<li><a class="reference internal" href="#distutils">distutils</a></li>
<li><a class="reference internal" href="#enum">enum</a></li>
<li><a class="reference internal" href="#functools">functools</a></li>
<li><a class="reference internal" href="#gc">gc</a></li>
<li><a class="reference internal" href="#hmac">hmac</a></li>
<li><a class="reference internal" href="#http-client">http.client</a></li>
<li><a class="reference internal" href="#http-server">http.server</a></li>
<li><a class="reference internal" href="#idlelib-and-idle">idlelib and IDLE</a></li>
<li><a class="reference internal" href="#importlib">importlib</a></li>
<li><a class="reference internal" href="#io">io</a></li>
<li><a class="reference internal" href="#ipaddress">ipaddress</a></li>
<li><a class="reference internal" href="#itertools">itertools</a></li>
<li><a class="reference internal" href="#locale">locale</a></li>
<li><a class="reference internal" href="#logging">logging</a></li>
<li><a class="reference internal" href="#math">math</a></li>
<li><a class="reference internal" href="#mimetypes">mimetypes</a></li>
<li><a class="reference internal" href="#msilib">msilib</a></li>
<li><a class="reference internal" href="#multiprocessing">multiprocessing</a></li>
<li><a class="reference internal" href="#os">os</a></li>
<li><a class="reference internal" href="#pathlib">pathlib</a></li>
<li><a class="reference internal" href="#pdb">pdb</a></li>
<li><a class="reference internal" href="#py-compile">py_compile</a></li>
<li><a class="reference internal" href="#pydoc">pydoc</a></li>
<li><a class="reference internal" href="#queue">queue</a></li>
<li><a class="reference internal" href="#re">re</a></li>
<li><a class="reference internal" href="#signal">signal</a></li>
<li><a class="reference internal" href="#socket">socket</a></li>
<li><a class="reference internal" href="#socketserver">socketserver</a></li>
<li><a class="reference internal" href="#sqlite3">sqlite3</a></li>
<li><a class="reference internal" href="#ssl">ssl</a></li>
<li><a class="reference internal" href="#string">string</a></li>
<li><a class="reference internal" href="#subprocess">subprocess</a></li>
<li><a class="reference internal" href="#sys">sys</a></li>
<li><a class="reference internal" href="#time">time</a></li>
<li><a class="reference internal" href="#tkinter">tkinter</a></li>
<li><a class="reference internal" href="#tracemalloc">tracemalloc</a></li>
<li><a class="reference internal" href="#types">types</a></li>
<li><a class="reference internal" href="#unicodedata">unicodedata</a></li>
<li><a class="reference internal" href="#unittest">unittest</a></li>
<li><a class="reference internal" href="#unittest-mock">unittest.mock</a></li>
<li><a class="reference internal" href="#urllib-parse">urllib.parse</a></li>
<li><a class="reference internal" href="#uu">uu</a></li>
<li><a class="reference internal" href="#uuid">uuid</a></li>
<li><a class="reference internal" href="#warnings">warnings</a></li>
<li><a class="reference internal" href="#xml-etree">xml.etree</a></li>
<li><a class="reference internal" href="#xmlrpc-server">xmlrpc.server</a></li>
<li><a class="reference internal" href="#zipapp">zipapp</a></li>
<li><a class="reference internal" href="#zipfile">zipfile</a></li>
</ul>
</li>
<li><a class="reference internal" href="#c-api-changes">C API Changes</a></li>
<li><a class="reference internal" href="#build-changes">Build Changes</a></li>
<li><a class="reference internal" href="#optimizations">Optimizations</a></li>
<li><a class="reference internal" href="#other-cpython-implementation-changes">Other CPython Implementation Changes</a></li>
<li><a class="reference internal" href="#deprecated-python-behavior">Deprecated Python Behavior</a></li>
<li><a class="reference internal" href="#deprecated-python-modules-functions-and-methods">Deprecated Python modules, functions and methods</a><ul>
<li><a class="reference internal" href="#aifc">aifc</a></li>
<li><a class="reference internal" href="#whatsnew37-asyncio-deprecated">asyncio</a></li>
<li><a class="reference internal" href="#id3">collections</a></li>
<li><a class="reference internal" href="#id4">dbm</a></li>
<li><a class="reference internal" href="#id5">enum</a></li>
<li><a class="reference internal" href="#gettext">gettext</a></li>
<li><a class="reference internal" href="#id6">importlib</a></li>
<li><a class="reference internal" href="#id7">locale</a></li>
<li><a class="reference internal" href="#macpath">macpath</a></li>
<li><a class="reference internal" href="#threading">threading</a></li>
<li><a class="reference internal" href="#id8">socket</a></li>
<li><a class="reference internal" href="#id9">ssl</a></li>
<li><a class="reference internal" href="#sunau">sunau</a></li>
<li><a class="reference internal" href="#id10">sys</a></li>
<li><a class="reference internal" href="#wave">wave</a></li>
</ul>
</li>
<li><a class="reference internal" href="#deprecated-functions-and-types-of-the-c-api">Deprecated functions and types of the C API</a></li>
<li><a class="reference internal" href="#platform-support-removals">Platform Support Removals</a></li>
<li><a class="reference internal" href="#api-and-feature-removals">API and Feature Removals</a></li>
<li><a class="reference internal" href="#module-removals">Module Removals</a></li>
<li><a class="reference internal" href="#windows-only-changes">Windows-only Changes</a></li>
<li><a class="reference internal" href="#porting-to-python-3-7">Porting to Python 3.7</a><ul>
<li><a class="reference internal" href="#changes-in-python-behavior">Changes in Python Behavior</a></li>
<li><a class="reference internal" href="#changes-in-the-python-api">Changes in the Python API</a></li>
<li><a class="reference internal" href="#changes-in-the-c-api">Changes in the C API</a></li>
<li><a class="reference internal" href="#cpython-bytecode-changes">CPython bytecode changes</a></li>
<li><a class="reference internal" href="#id12">Windows-only Changes</a></li>
<li><a class="reference internal" href="#id13">Other CPython implementation changes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#notable-changes-in-python-3-7-1">Notable changes in Python 3.7.1</a></li>
<li><a class="reference internal" href="#notable-changes-in-python-3-7-2">Notable changes in Python 3.7.2</a></li>
<li><a class="reference internal" href="#notable-changes-in-python-3-7-6">Notable changes in Python 3.7.6</a></li>
<li><a class="reference internal" href="#notable-changes-in-python-3-7-10">Notable changes in Python 3.7.10</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="3.8.html"
                        title="previous chapter">What’s New In Python 3.8</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="3.6.html"
                        title="next chapter">What’s New In Python 3.6</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">Report a Bug</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/3.8/Doc/whatsnew/3.7.rst"
            rel="nofollow">Show Source
        </a>
      </li>
    </ul>
  </div>
        </nav>
    </div>
</div>

  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="3.6.html" title="What’s New In Python 3.6"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="3.8.html" title="What’s New In Python 3.8"
             accesskey="P">previous</a> |</li>

          <li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
          <li><a href="https://www.python.org/">Python</a> &#187;</li>
          <li class="switchers">
            <div class="language_switcher_placeholder"></div>
            <div class="version_switcher_placeholder"></div>
          </li>
          <li>
              
          </li>
    <li id="cpython-language-and-version">
      <a href="../index.html">3.8.13 Documentation</a> &#187;
    </li>

          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">What’s New in Python</a> &#187;</li>
                <li class="right">
                    

    <div class="inline-search" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" aria-label="Quick search" type="text" name="q" />
          <input type="submit" value="Go" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
                     |
                </li>
            
      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="what-s-new-in-python-3-7">
<h1>What’s New In Python 3.7<a class="headerlink" href="#what-s-new-in-python-3-7" title="Permalink to this headline">¶</a></h1>
<dl class="field-list simple">
<dt class="field-odd">Editor</dt>
<dd class="field-odd"><p>Elvis Pranskevichus &lt;<a class="reference external" href="mailto:elvis&#37;&#52;&#48;magic&#46;io">elvis<span>&#64;</span>magic<span>&#46;</span>io</a>&gt;</p>
</dd>
</dl>
<p>This article explains the new features in Python 3.7, compared to 3.6.
Python 3.7 was released on June 27, 2018.
For full details, see the <a class="reference internal" href="changelog.html#changelog"><span class="std std-ref">changelog</span></a>.</p>
<div class="section" id="summary-release-highlights">
<h2>Summary – Release Highlights<a class="headerlink" href="#summary-release-highlights" title="Permalink to this headline">¶</a></h2>
<p>New syntax features:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#whatsnew37-pep563"><span class="std std-ref">PEP 563</span></a>, postponed evaluation of type annotations.</p></li>
</ul>
<p>Backwards incompatible syntax changes:</p>
<ul class="simple">
<li><p><a class="reference internal" href="../reference/compound_stmts.html#async"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span></code></a> and <a class="reference internal" href="../reference/expressions.html#await"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">await</span></code></a> are now reserved keywords.</p></li>
</ul>
<p>New library modules:</p>
<ul class="simple">
<li><p><a class="reference internal" href="../library/contextvars.html#module-contextvars" title="contextvars: Context Variables"><code class="xref py py-mod docutils literal notranslate"><span class="pre">contextvars</span></code></a>: <a class="reference internal" href="#whatsnew37-pep567"><span class="std std-ref">PEP 567 – Context Variables</span></a></p></li>
<li><p><a class="reference internal" href="../library/dataclasses.html#module-dataclasses" title="dataclasses: Generate special methods on user-defined classes."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dataclasses</span></code></a>: <a class="reference internal" href="#whatsnew37-pep557"><span class="std std-ref">PEP 557 – Data Classes</span></a></p></li>
<li><p><a class="reference internal" href="#whatsnew37-importlib-resources"><span class="std std-ref">importlib.resources</span></a></p></li>
</ul>
<p>New built-in features:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#whatsnew37-pep553"><span class="std std-ref">PEP 553</span></a>, the new <a class="reference internal" href="../library/functions.html#breakpoint" title="breakpoint"><code class="xref py py-func docutils literal notranslate"><span class="pre">breakpoint()</span></code></a> function.</p></li>
</ul>
<p>Python data model improvements:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#whatsnew37-pep562"><span class="std std-ref">PEP 562</span></a>, customization of access to
module attributes.</p></li>
<li><p><a class="reference internal" href="#whatsnew37-pep560"><span class="std std-ref">PEP 560</span></a>, core support for typing module and
generic types.</p></li>
<li><p>the insertion-order preservation nature of <a class="reference internal" href="../library/stdtypes.html#typesmapping"><span class="std std-ref">dict</span></a>
objects <a class="reference external" href="https://mail.python.org/pipermail/python-dev/2017-December/151283.html">has been declared</a> to be an official
part of the Python language spec.</p></li>
</ul>
<p>Significant improvements in the standard library:</p>
<ul class="simple">
<li><p>The <a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code></a> module has received new features, significant
<a class="reference internal" href="#whatsnew37-asyncio"><span class="std std-ref">usability and performance improvements</span></a>.</p></li>
<li><p>The <a class="reference internal" href="../library/time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a> module gained support for
<a class="reference internal" href="#whatsnew37-pep564"><span class="std std-ref">functions with nanosecond resolution</span></a>.</p></li>
</ul>
<p>CPython implementation improvements:</p>
<ul class="simple">
<li><p>Avoiding the use of ASCII as a default text encoding:</p>
<ul>
<li><p><a class="reference internal" href="#whatsnew37-pep538"><span class="std std-ref">PEP 538</span></a>, legacy C locale coercion</p></li>
<li><p><a class="reference internal" href="#whatsnew37-pep540"><span class="std std-ref">PEP 540</span></a>, forced UTF-8 runtime mode</p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#whatsnew37-pep552"><span class="std std-ref">PEP 552</span></a>, deterministic .pycs</p></li>
<li><p><a class="reference internal" href="#whatsnew37-devmode"><span class="std std-ref">the new development runtime mode</span></a></p></li>
<li><p><a class="reference internal" href="#whatsnew37-pep565"><span class="std std-ref">PEP 565</span></a>, improved <a class="reference internal" href="../library/exceptions.html#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a>
handling</p></li>
</ul>
<p>C API improvements:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#whatsnew37-pep539"><span class="std std-ref">PEP 539</span></a>, new C API for thread-local storage</p></li>
</ul>
<p>Documentation improvements:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#whatsnew37-pep545"><span class="std std-ref">PEP 545</span></a>, Python documentation translations</p></li>
<li><p>New documentation translations: <a class="reference external" href="https://docs.python.org/ja/">Japanese</a>,
<a class="reference external" href="https://docs.python.org/fr/">French</a>, and
<a class="reference external" href="https://docs.python.org/ko/">Korean</a>.</p></li>
</ul>
<p>This release features notable performance improvements in many areas.
The <a class="reference internal" href="#whatsnew37-perf"><span class="std std-ref">Optimizations</span></a> section lists them in detail.</p>
<p>For a list of changes that may affect compatibility with previous Python
releases please refer to the <a class="reference internal" href="#porting-to-python-37"><span class="std std-ref">Porting to Python 3.7</span></a> section.</p>
</div>
<div class="section" id="new-features">
<h2>New Features<a class="headerlink" href="#new-features" title="Permalink to this headline">¶</a></h2>
<div class="section" id="pep-563-postponed-evaluation-of-annotations">
<span id="whatsnew37-pep563"></span><h3>PEP 563: Postponed Evaluation of Annotations<a class="headerlink" href="#pep-563-postponed-evaluation-of-annotations" title="Permalink to this headline">¶</a></h3>
<p>The advent of type hints in Python uncovered two glaring usability issues
with the functionality of annotations added in <span class="target" id="index-0"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-3107"><strong>PEP 3107</strong></a> and refined
further in <span class="target" id="index-1"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0526"><strong>PEP 526</strong></a>:</p>
<ul class="simple">
<li><p>annotations could only use names which were already available in the
current scope, in other words they didn’t support forward references
of any kind; and</p></li>
<li><p>annotating source code had adverse effects on startup time of Python
programs.</p></li>
</ul>
<p>Both of these issues are fixed by postponing the evaluation of
annotations.  Instead of compiling code which executes expressions in
annotations at their definition time, the compiler stores the annotation
in a string form equivalent to the AST of the expression in question.
If needed, annotations can be resolved at runtime using
<a class="reference internal" href="../library/typing.html#typing.get_type_hints" title="typing.get_type_hints"><code class="xref py py-func docutils literal notranslate"><span class="pre">typing.get_type_hints()</span></code></a>.  In the common case where this is not
required, the annotations are cheaper to store (since short strings
are interned by the interpreter) and make startup time faster.</p>
<p>Usability-wise, annotations now support forward references, making the
following syntax valid:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">C</span><span class="p">:</span>
    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_string</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">source</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">C</span><span class="p">:</span>
        <span class="o">...</span>

    <span class="k">def</span> <span class="nf">validate_b</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">:</span> <span class="n">B</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
        <span class="o">...</span>

<span class="k">class</span> <span class="nc">B</span><span class="p">:</span>
    <span class="o">...</span>
</pre></div>
</div>
<p>Since this change breaks compatibility, the new behavior needs to be enabled
on a per-module basis in Python 3.7 using a <a class="reference internal" href="../library/__future__.html#module-__future__" title="__future__: Future statement definitions"><code class="xref py py-mod docutils literal notranslate"><span class="pre">__future__</span></code></a> import:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">annotations</span>
</pre></div>
</div>
<p>It will become the default in Python 3.10.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><span class="target" id="index-2"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0563"><strong>PEP 563</strong></a> – Postponed evaluation of annotations</dt><dd><p>PEP written and implemented by Łukasz Langa.</p>
</dd>
</dl>
</div>
</div>
<div class="section" id="pep-538-legacy-c-locale-coercion">
<span id="whatsnew37-pep538"></span><h3>PEP 538: Legacy C Locale Coercion<a class="headerlink" href="#pep-538-legacy-c-locale-coercion" title="Permalink to this headline">¶</a></h3>
<p>An ongoing challenge within the Python 3 series has been determining a sensible
default strategy for handling the “7-bit ASCII” text encoding assumption
currently implied by the use of the default C or POSIX locale on non-Windows
platforms.</p>
<p><span class="target" id="index-3"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0538"><strong>PEP 538</strong></a> updates the default interpreter command line interface to
automatically coerce that locale to an available UTF-8 based locale as
described in the documentation of the new <span class="target" id="index-4"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONCOERCECLOCALE"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONCOERCECLOCALE</span></code></a>
environment variable. Automatically setting <code class="docutils literal notranslate"><span class="pre">LC_CTYPE</span></code> this way means that
both the core interpreter and locale-aware C extensions (such as
<a class="reference internal" href="../library/readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">readline</span></code></a>) will assume the use of UTF-8 as the default text encoding,
rather than ASCII.</p>
<p>The platform support definition in <span class="target" id="index-5"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0011"><strong>PEP 11</strong></a> has also been updated to limit
full text handling support to suitably configured non-ASCII based locales.</p>
<p>As part of this change, the default error handler for <a class="reference internal" href="../library/sys.html#sys.stdin" title="sys.stdin"><code class="xref py py-data docutils literal notranslate"><span class="pre">stdin</span></code></a> and
<a class="reference internal" href="../library/sys.html#sys.stdout" title="sys.stdout"><code class="xref py py-data docutils literal notranslate"><span class="pre">stdout</span></code></a> is now <code class="docutils literal notranslate"><span class="pre">surrogateescape</span></code> (rather than <code class="docutils literal notranslate"><span class="pre">strict</span></code>) when
using any of the defined coercion target locales (currently <code class="docutils literal notranslate"><span class="pre">C.UTF-8</span></code>,
<code class="docutils literal notranslate"><span class="pre">C.utf8</span></code>, and <code class="docutils literal notranslate"><span class="pre">UTF-8</span></code>).  The default error handler for <a class="reference internal" href="../library/sys.html#sys.stderr" title="sys.stderr"><code class="xref py py-data docutils literal notranslate"><span class="pre">stderr</span></code></a>
continues to be <code class="docutils literal notranslate"><span class="pre">backslashreplace</span></code>, regardless of locale.</p>
<p>Locale coercion is silent by default, but to assist in debugging potentially
locale related integration problems, explicit warnings (emitted directly on
<a class="reference internal" href="../library/sys.html#sys.stderr" title="sys.stderr"><code class="xref py py-data docutils literal notranslate"><span class="pre">stderr</span></code></a>) can be requested by setting <code class="docutils literal notranslate"><span class="pre">PYTHONCOERCECLOCALE=warn</span></code>.
This setting will also cause the Python runtime to emit a warning if the
legacy C locale remains active when the core interpreter is initialized.</p>
<p>While <span class="target" id="index-6"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0538"><strong>PEP 538</strong></a>’s locale coercion has the benefit of also affecting extension
modules (such as GNU <code class="docutils literal notranslate"><span class="pre">readline</span></code>), as well as child processes (including those
running non-Python applications and older versions of Python), it has the
downside of requiring that a suitable target locale be present on the running
system. To better handle the case where no suitable target locale is available
(as occurs on RHEL/CentOS 7, for example), Python 3.7 also implements
<a class="reference internal" href="#whatsnew37-pep540"><span class="std std-ref">PEP 540: Forced UTF-8 Runtime Mode</span></a>.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><span class="target" id="index-7"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0538"><strong>PEP 538</strong></a> – Coercing the legacy C locale to a UTF-8 based locale</dt><dd><p>PEP written and implemented by Nick Coghlan.</p>
</dd>
</dl>
</div>
</div>
<div class="section" id="pep-540-forced-utf-8-runtime-mode">
<span id="whatsnew37-pep540"></span><h3>PEP 540: Forced UTF-8 Runtime Mode<a class="headerlink" href="#pep-540-forced-utf-8-runtime-mode" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../using/cmdline.html#id5"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a> <code class="docutils literal notranslate"><span class="pre">utf8</span></code> command line option and <span class="target" id="index-8"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONUTF8"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONUTF8</span></code></a>
environment variable can be used to enable the CPython <em>UTF-8 mode</em>.</p>
<p>When in UTF-8 mode, CPython ignores the locale settings, and uses the
UTF-8 encoding by default.  The error handlers for <a class="reference internal" href="../library/sys.html#sys.stdin" title="sys.stdin"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdin</span></code></a> and
<a class="reference internal" href="../library/sys.html#sys.stdout" title="sys.stdout"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdout</span></code></a> streams are set to <code class="docutils literal notranslate"><span class="pre">surrogateescape</span></code>.</p>
<p>The forced UTF-8 mode can be used to change the text handling behavior in
an embedded Python interpreter without changing the locale settings of
an embedding application.</p>
<p>While <span class="target" id="index-9"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0540"><strong>PEP 540</strong></a>’s UTF-8 mode has the benefit of working regardless of which
locales are available on the running system, it has the downside of having no
effect on extension modules (such as GNU <code class="docutils literal notranslate"><span class="pre">readline</span></code>), child processes running
non-Python applications, and child processes running older versions of Python.
To reduce the risk of corrupting text data when communicating with such
components, Python 3.7 also implements <a class="reference internal" href="#whatsnew37-pep540"><span class="std std-ref">PEP 540: Forced UTF-8 Runtime Mode</span></a>).</p>
<p>The UTF-8 mode is enabled by default when the locale is <code class="docutils literal notranslate"><span class="pre">C</span></code> or <code class="docutils literal notranslate"><span class="pre">POSIX</span></code>, and
the <span class="target" id="index-10"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0538"><strong>PEP 538</strong></a> locale coercion feature fails to change it to a UTF-8 based
alternative (whether that failure is due to <code class="docutils literal notranslate"><span class="pre">PYTHONCOERCECLOCALE=0</span></code> being set,
<code class="docutils literal notranslate"><span class="pre">LC_ALL</span></code> being set, or the lack of a suitable target locale).</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><span class="target" id="index-11"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0540"><strong>PEP 540</strong></a> – Add a new UTF-8 mode</dt><dd><p>PEP written and implemented by Victor Stinner</p>
</dd>
</dl>
</div>
</div>
<div class="section" id="pep-553-built-in-breakpoint">
<span id="whatsnew37-pep553"></span><h3>PEP 553: Built-in <code class="docutils literal notranslate"><span class="pre">breakpoint()</span></code><a class="headerlink" href="#pep-553-built-in-breakpoint" title="Permalink to this headline">¶</a></h3>
<p>Python 3.7 includes the new built-in <a class="reference internal" href="../library/functions.html#breakpoint" title="breakpoint"><code class="xref py py-func docutils literal notranslate"><span class="pre">breakpoint()</span></code></a> function as
an easy and consistent way to enter the Python debugger.</p>
<p>Built-in <code class="docutils literal notranslate"><span class="pre">breakpoint()</span></code> calls <a class="reference internal" href="../library/sys.html#sys.breakpointhook" title="sys.breakpointhook"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.breakpointhook()</span></code></a>.  By default, the
latter imports <a class="reference internal" href="../library/pdb.html#module-pdb" title="pdb: The Python debugger for interactive interpreters."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pdb</span></code></a> and then calls <code class="docutils literal notranslate"><span class="pre">pdb.set_trace()</span></code>, but by binding
<code class="docutils literal notranslate"><span class="pre">sys.breakpointhook()</span></code> to the function of your choosing, <code class="docutils literal notranslate"><span class="pre">breakpoint()</span></code> can
enter any debugger. Additionally, the environment variable
<span class="target" id="index-12"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONBREAKPOINT"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONBREAKPOINT</span></code></a> can be set to the callable of your debugger of
choice.  Set <code class="docutils literal notranslate"><span class="pre">PYTHONBREAKPOINT=0</span></code> to completely disable built-in
<code class="docutils literal notranslate"><span class="pre">breakpoint()</span></code>.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><span class="target" id="index-13"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0553"><strong>PEP 553</strong></a> – Built-in breakpoint()</dt><dd><p>PEP written and implemented by Barry Warsaw</p>
</dd>
</dl>
</div>
</div>
<div class="section" id="pep-539-new-c-api-for-thread-local-storage">
<span id="whatsnew37-pep539"></span><h3>PEP 539: New C API for Thread-Local Storage<a class="headerlink" href="#pep-539-new-c-api-for-thread-local-storage" title="Permalink to this headline">¶</a></h3>
<p>While Python provides a C API for thread-local storage support; the existing
<a class="reference internal" href="../c-api/init.html#thread-local-storage-api"><span class="std std-ref">Thread Local Storage (TLS) API</span></a> has used
<code class="xref c c-type docutils literal notranslate"><span class="pre">int</span></code> to represent TLS keys across all platforms.  This has not
generally been a problem for officially-support platforms, but that is neither
POSIX-compliant, nor portable in any practical sense.</p>
<p><span class="target" id="index-14"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0539"><strong>PEP 539</strong></a> changes this by providing a new <a class="reference internal" href="../c-api/init.html#thread-specific-storage-api"><span class="std std-ref">Thread Specific Storage (TSS)
API</span></a> to CPython which supersedes use of the
existing TLS API within the CPython interpreter, while deprecating the existing
API.  The TSS API uses a new type <a class="reference internal" href="../c-api/init.html#c.Py_tss_t" title="Py_tss_t"><code class="xref c c-type docutils literal notranslate"><span class="pre">Py_tss_t</span></code></a> instead of <code class="xref c c-type docutils literal notranslate"><span class="pre">int</span></code>
to represent TSS keys–an opaque type the definition of which may depend on
the underlying TLS implementation.  Therefore, this will allow to build CPython
on platforms where the native TLS key is defined in a way that cannot be safely
cast to <code class="xref c c-type docutils literal notranslate"><span class="pre">int</span></code>.</p>
<p>Note that on platforms where the native TLS key is defined in a way that cannot
be safely cast to <code class="xref c c-type docutils literal notranslate"><span class="pre">int</span></code>, all functions of the existing TLS API will be
no-op and immediately return failure. This indicates clearly that the old API
is not supported on platforms where it cannot be used reliably, and that no
effort will be made to add such support.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><span class="target" id="index-15"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0539"><strong>PEP 539</strong></a> – A New C-API for Thread-Local Storage in CPython</dt><dd><p>PEP written by Erik M. Bray; implementation by Masayuki Yamamoto.</p>
</dd>
</dl>
</div>
</div>
<div class="section" id="pep-562-customization-of-access-to-module-attributes">
<span id="whatsnew37-pep562"></span><h3>PEP 562: Customization of Access to Module Attributes<a class="headerlink" href="#pep-562-customization-of-access-to-module-attributes" title="Permalink to this headline">¶</a></h3>
<p>Python 3.7 allows defining <a class="reference internal" href="../reference/datamodel.html#object.__getattr__" title="object.__getattr__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__getattr__()</span></code></a> on modules and will call
it whenever a module attribute is otherwise not found.  Defining
<a class="reference internal" href="../reference/datamodel.html#object.__dir__" title="object.__dir__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__dir__()</span></code></a> on modules is now also allowed.</p>
<p>A typical example of where this may be useful is module attribute deprecation
and lazy loading.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><span class="target" id="index-16"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0562"><strong>PEP 562</strong></a> – Module <code class="docutils literal notranslate"><span class="pre">__getattr__</span></code> and <code class="docutils literal notranslate"><span class="pre">__dir__</span></code></dt><dd><p>PEP written and implemented by Ivan Levkivskyi</p>
</dd>
</dl>
</div>
</div>
<div class="section" id="pep-564-new-time-functions-with-nanosecond-resolution">
<span id="whatsnew37-pep564"></span><h3>PEP 564: New Time Functions With Nanosecond Resolution<a class="headerlink" href="#pep-564-new-time-functions-with-nanosecond-resolution" title="Permalink to this headline">¶</a></h3>
<p>The resolution of clocks in modern systems can exceed the limited precision
of a floating point number returned by the <a class="reference internal" href="../library/time.html#time.time" title="time.time"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.time()</span></code></a> function
and its variants.  To avoid loss of precision, <span class="target" id="index-17"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0564"><strong>PEP 564</strong></a> adds six new
“nanosecond” variants of the existing timer functions to the <a class="reference internal" href="../library/time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a>
module:</p>
<ul class="simple">
<li><p><a class="reference internal" href="../library/time.html#time.clock_gettime_ns" title="time.clock_gettime_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.clock_gettime_ns()</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/time.html#time.clock_settime_ns" title="time.clock_settime_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.clock_settime_ns()</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/time.html#time.monotonic_ns" title="time.monotonic_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.monotonic_ns()</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/time.html#time.perf_counter_ns" title="time.perf_counter_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.perf_counter_ns()</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/time.html#time.process_time_ns" title="time.process_time_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.process_time_ns()</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/time.html#time.time_ns" title="time.time_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.time_ns()</span></code></a></p></li>
</ul>
<p>The new functions return the number of nanoseconds as an integer value.</p>
<p><a class="reference external" href="https://www.python.org/dev/peps/pep-0564/#annex-clocks-resolution-in-python">Measurements</a>
show that on Linux and Windows the resolution of <a class="reference internal" href="../library/time.html#time.time_ns" title="time.time_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.time_ns()</span></code></a> is
approximately 3 times better than that of <a class="reference internal" href="../library/time.html#time.time" title="time.time"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.time()</span></code></a>.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><span class="target" id="index-18"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0564"><strong>PEP 564</strong></a> – Add new time functions with nanosecond resolution</dt><dd><p>PEP written and implemented by Victor Stinner</p>
</dd>
</dl>
</div>
</div>
<div class="section" id="pep-565-show-deprecationwarning-in-main">
<span id="whatsnew37-pep565"></span><h3>PEP 565: Show DeprecationWarning in <code class="docutils literal notranslate"><span class="pre">__main__</span></code><a class="headerlink" href="#pep-565-show-deprecationwarning-in-main" title="Permalink to this headline">¶</a></h3>
<p>The default handling of <a class="reference internal" href="../library/exceptions.html#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a> has been changed such that
these warnings are once more shown by default, but only when the code
triggering them is running directly in the <a class="reference internal" href="../library/__main__.html#module-__main__" title="__main__: The environment where the top-level script is run."><code class="xref py py-mod docutils literal notranslate"><span class="pre">__main__</span></code></a> module.  As a result,
developers of single file scripts and those using Python interactively should
once again start seeing deprecation warnings for the APIs they use, but
deprecation warnings triggered by imported application, library and framework
modules will continue to be hidden by default.</p>
<p>As a result of this change, the standard library now allows developers to choose
between three different deprecation warning behaviours:</p>
<ul class="simple">
<li><p><a class="reference internal" href="../library/exceptions.html#FutureWarning" title="FutureWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FutureWarning</span></code></a>: always displayed by default, recommended for warnings
intended to be seen by application end users (e.g. for deprecated application
configuration settings).</p></li>
<li><p><a class="reference internal" href="../library/exceptions.html#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a>: displayed by default only in <a class="reference internal" href="../library/__main__.html#module-__main__" title="__main__: The environment where the top-level script is run."><code class="xref py py-mod docutils literal notranslate"><span class="pre">__main__</span></code></a> and when
running tests, recommended for warnings intended to be seen by other Python
developers where a version upgrade may result in changed behaviour or an
error.</p></li>
<li><p><a class="reference internal" href="../library/exceptions.html#PendingDeprecationWarning" title="PendingDeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">PendingDeprecationWarning</span></code></a>: displayed by default only when running
tests, intended for cases where a future version upgrade will change the
warning category to <a class="reference internal" href="../library/exceptions.html#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a> or <a class="reference internal" href="../library/exceptions.html#FutureWarning" title="FutureWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FutureWarning</span></code></a>.</p></li>
</ul>
<p>Previously both <a class="reference internal" href="../library/exceptions.html#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a> and <a class="reference internal" href="../library/exceptions.html#PendingDeprecationWarning" title="PendingDeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">PendingDeprecationWarning</span></code></a>
were only visible when running tests, which meant that developers primarily
writing single file scripts or using Python interactively could be surprised
by breaking changes in the APIs they used.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><span class="target" id="index-19"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0565"><strong>PEP 565</strong></a> – Show DeprecationWarning in <code class="docutils literal notranslate"><span class="pre">__main__</span></code></dt><dd><p>PEP written and implemented by Nick Coghlan</p>
</dd>
</dl>
</div>
</div>
<div class="section" id="pep-560-core-support-for-typing-module-and-generic-types">
<span id="whatsnew37-pep560"></span><h3>PEP 560: Core Support for <code class="docutils literal notranslate"><span class="pre">typing</span></code> module and Generic Types<a class="headerlink" href="#pep-560-core-support-for-typing-module-and-generic-types" title="Permalink to this headline">¶</a></h3>
<p>Initially <span class="target" id="index-20"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0484"><strong>PEP 484</strong></a> was designed in such way that it would not introduce <em>any</em>
changes to the core CPython interpreter. Now type hints and the <a class="reference internal" href="../library/typing.html#module-typing" title="typing: Support for type hints (see :pep:`484`)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">typing</span></code></a>
module are extensively used by the community, so this restriction is removed.
The PEP introduces two special methods <a class="reference internal" href="../reference/datamodel.html#object.__class_getitem__" title="object.__class_getitem__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__class_getitem__()</span></code></a> and
<code class="docutils literal notranslate"><span class="pre">__mro_entries__</span></code>, these methods are now used by most classes and special
constructs in <a class="reference internal" href="../library/typing.html#module-typing" title="typing: Support for type hints (see :pep:`484`)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">typing</span></code></a>. As a result, the speed of various operations
with types increased up to 7 times, the generic types can be used without
metaclass conflicts, and several long standing bugs in <a class="reference internal" href="../library/typing.html#module-typing" title="typing: Support for type hints (see :pep:`484`)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">typing</span></code></a> module are
fixed.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><span class="target" id="index-21"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0560"><strong>PEP 560</strong></a> – Core support for typing module and generic types</dt><dd><p>PEP written and implemented by Ivan Levkivskyi</p>
</dd>
</dl>
</div>
</div>
<div class="section" id="pep-552-hash-based-pyc-files">
<span id="whatsnew37-pep552"></span><h3>PEP 552: Hash-based .pyc Files<a class="headerlink" href="#pep-552-hash-based-pyc-files" title="Permalink to this headline">¶</a></h3>
<p>Python has traditionally checked the up-to-dateness of bytecode cache files
(i.e., <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files) by comparing the source metadata (last-modified timestamp
and size) with source metadata saved in the cache file header when it was
generated. While effective, this invalidation method has its drawbacks.  When
filesystem timestamps are too coarse, Python can miss source updates, leading to
user confusion. Additionally, having a timestamp in the cache file is
problematic for <a class="reference external" href="https://reproducible-builds.org/">build reproducibility</a> and
content-based build systems.</p>
<p><span class="target" id="index-22"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0552"><strong>PEP 552</strong></a> extends the pyc format to allow the hash of the source file to be
used for invalidation instead of the source timestamp. Such <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files are
called “hash-based”. By default, Python still uses timestamp-based invalidation
and does not generate hash-based <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files at runtime. Hash-based <code class="docutils literal notranslate"><span class="pre">.pyc</span></code>
files may be generated with <a class="reference internal" href="../library/py_compile.html#module-py_compile" title="py_compile: Generate byte-code files from Python source files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">py_compile</span></code></a> or <a class="reference internal" href="../library/compileall.html#module-compileall" title="compileall: Tools for byte-compiling all Python source files in a directory tree."><code class="xref py py-mod docutils literal notranslate"><span class="pre">compileall</span></code></a>.</p>
<p>Hash-based <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files come in two variants: checked and unchecked. Python
validates checked hash-based <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files against the corresponding source
files at runtime but doesn’t do so for unchecked hash-based pycs. Unchecked
hash-based <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files are a useful performance optimization for environments
where a system external to Python (e.g., the build system) is responsible for
keeping <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files up-to-date.</p>
<p>See <a class="reference internal" href="../reference/import.html#pyc-invalidation"><span class="std std-ref">Cached bytecode invalidation</span></a> for more information.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><span class="target" id="index-23"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0552"><strong>PEP 552</strong></a> – Deterministic pycs</dt><dd><p>PEP written and implemented by Benjamin Peterson</p>
</dd>
</dl>
</div>
</div>
<div class="section" id="pep-545-python-documentation-translations">
<span id="whatsnew37-pep545"></span><h3>PEP 545: Python Documentation Translations<a class="headerlink" href="#pep-545-python-documentation-translations" title="Permalink to this headline">¶</a></h3>
<p><span class="target" id="index-24"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0545"><strong>PEP 545</strong></a> describes the process of creating and maintaining Python
documentation translations.</p>
<p>Three new translations have been added:</p>
<ul class="simple">
<li><p>Japanese: <a class="reference external" href="https://docs.python.org/ja/">https://docs.python.org/ja/</a></p></li>
<li><p>French: <a class="reference external" href="https://docs.python.org/fr/">https://docs.python.org/fr/</a></p></li>
<li><p>Korean: <a class="reference external" href="https://docs.python.org/ko/">https://docs.python.org/ko/</a></p></li>
</ul>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><span class="target" id="index-25"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0545"><strong>PEP 545</strong></a> – Python Documentation Translations</dt><dd><p>PEP written and implemented by Julien Palard, Inada Naoki, and
Victor Stinner.</p>
</dd>
</dl>
</div>
</div>
<div class="section" id="development-runtime-mode-x-dev">
<span id="whatsnew37-devmode"></span><h3>Development Runtime Mode: -X dev<a class="headerlink" href="#development-runtime-mode-x-dev" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../using/cmdline.html#id5"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a> <code class="docutils literal notranslate"><span class="pre">dev</span></code> command line option or the new
<span class="target" id="index-26"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONDEVMODE"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONDEVMODE</span></code></a> environment variable can be used to enable
CPython’s <em>development mode</em>.  When in development mode, CPython performs
additional runtime checks that are too expensive to be enabled by default.
See <a class="reference internal" href="../using/cmdline.html#id5"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a> <code class="docutils literal notranslate"><span class="pre">dev</span></code> documentation for the full description of the effects
of this mode.</p>
</div>
</div>
<div class="section" id="other-language-changes">
<h2>Other Language Changes<a class="headerlink" href="#other-language-changes" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><p>An <a class="reference internal" href="../reference/expressions.html#await"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">await</span></code></a> expression and comprehensions containing an
<a class="reference internal" href="../reference/compound_stmts.html#async-for"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span> <span class="pre">for</span></code></a> clause were illegal in the expressions in
<a class="reference internal" href="../reference/lexical_analysis.html#f-strings"><span class="std std-ref">formatted string literals</span></a> due to a problem with the
implementation.  In Python 3.7 this restriction was lifted.</p></li>
<li><p>More than 255 arguments can now be passed to a function, and a function can
now have more than 255 parameters. (Contributed by Serhiy Storchaka in
<a class="reference external" href="https://bugs.python.org/issue12844">bpo-12844</a> and <a class="reference external" href="https://bugs.python.org/issue18896">bpo-18896</a>.)</p></li>
<li><p><a class="reference internal" href="../library/stdtypes.html#bytes.fromhex" title="bytes.fromhex"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bytes.fromhex()</span></code></a> and <a class="reference internal" href="../library/stdtypes.html#bytearray.fromhex" title="bytearray.fromhex"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bytearray.fromhex()</span></code></a> now ignore all ASCII
whitespace, not only spaces. (Contributed by Robert Xiao in <a class="reference external" href="https://bugs.python.org/issue28927">bpo-28927</a>.)</p></li>
<li><p><a class="reference internal" href="../library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>, <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a>, and <a class="reference internal" href="../library/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a> gained support for
the new <a class="reference internal" href="../library/stdtypes.html#str.isascii" title="str.isascii"><code class="xref py py-meth docutils literal notranslate"><span class="pre">isascii()</span></code></a> method, which can be used to
test if a string or bytes contain only the ASCII characters.
(Contributed by INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue32677">bpo-32677</a>.)</p></li>
<li><p><a class="reference internal" href="../library/exceptions.html#ImportError" title="ImportError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ImportError</span></code></a> now displays module name and module <code class="docutils literal notranslate"><span class="pre">__file__</span></code> path when
<code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">...</span> <span class="pre">import</span> <span class="pre">...</span></code> fails. (Contributed by Matthias Bussonnier in
<a class="reference external" href="https://bugs.python.org/issue29546">bpo-29546</a>.)</p></li>
<li><p>Circular imports involving absolute imports with binding a submodule to
a name are now supported.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue30024">bpo-30024</a>.)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">object.__format__(x,</span> <span class="pre">'')</span></code> is now equivalent to <code class="docutils literal notranslate"><span class="pre">str(x)</span></code> rather than
<code class="docutils literal notranslate"><span class="pre">format(str(self),</span> <span class="pre">'')</span></code>.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue28974">bpo-28974</a>.)</p></li>
<li><p>In order to better support dynamic creation of stack traces,
<a class="reference internal" href="../library/types.html#types.TracebackType" title="types.TracebackType"><code class="xref py py-class docutils literal notranslate"><span class="pre">types.TracebackType</span></code></a> can now be instantiated from Python code, and
the <code class="docutils literal notranslate"><span class="pre">tb_next</span></code> attribute on <a class="reference internal" href="../reference/datamodel.html#traceback-objects"><span class="std std-ref">tracebacks</span></a> is now
writable.
(Contributed by Nathaniel J. Smith in <a class="reference external" href="https://bugs.python.org/issue30579">bpo-30579</a>.)</p></li>
<li><p>When using the <a class="reference internal" href="../using/cmdline.html#cmdoption-m"><code class="xref std std-option docutils literal notranslate"><span class="pre">-m</span></code></a> switch, <code class="docutils literal notranslate"><span class="pre">sys.path[0]</span></code> is now eagerly expanded
to the full starting directory path, rather than being left as the empty
directory (which allows imports from the <em>current</em> working directory at the
time when an import occurs)
(Contributed by Nick Coghlan in <a class="reference external" href="https://bugs.python.org/issue33053">bpo-33053</a>.)</p></li>
<li><p>The new <a class="reference internal" href="../using/cmdline.html#id5"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a> <code class="docutils literal notranslate"><span class="pre">importtime</span></code> option or the
<span class="target" id="index-27"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONPROFILEIMPORTTIME"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONPROFILEIMPORTTIME</span></code></a> environment variable can be used to show
the timing of each module import.
(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue31415">bpo-31415</a>.)</p></li>
</ul>
</div>
<div class="section" id="new-modules">
<h2>New Modules<a class="headerlink" href="#new-modules" title="Permalink to this headline">¶</a></h2>
<div class="section" id="contextvars">
<span id="whatsnew37-pep567"></span><h3>contextvars<a class="headerlink" href="#contextvars" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/contextvars.html#module-contextvars" title="contextvars: Context Variables"><code class="xref py py-mod docutils literal notranslate"><span class="pre">contextvars</span></code></a> module and a set of
<a class="reference internal" href="../c-api/contextvars.html#contextvarsobjects"><span class="std std-ref">new C APIs</span></a> introduce
support for <em>context variables</em>.  Context variables are conceptually
similar to thread-local variables.  Unlike TLS, context variables
support asynchronous code correctly.</p>
<p>The <a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code></a> and <a class="reference internal" href="../library/decimal.html#module-decimal" title="decimal: Implementation of the General Decimal Arithmetic  Specification."><code class="xref py py-mod docutils literal notranslate"><span class="pre">decimal</span></code></a> modules have been updated to use
and support context variables out of the box.  Particularly the active
decimal context is now stored in a context variable, which allows
decimal operations to work with the correct context in asynchronous code.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><span class="target" id="index-28"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0567"><strong>PEP 567</strong></a> – Context Variables</dt><dd><p>PEP written and implemented by Yury Selivanov</p>
</dd>
</dl>
</div>
</div>
<div class="section" id="dataclasses">
<span id="whatsnew37-pep557"></span><h3>dataclasses<a class="headerlink" href="#dataclasses" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/dataclasses.html#dataclasses.dataclass" title="dataclasses.dataclass"><code class="xref py py-func docutils literal notranslate"><span class="pre">dataclass()</span></code></a> decorator provides a way to declare
<em>data classes</em>.  A data class describes its attributes using class variable
annotations.  Its constructor and other magic methods, such as
<a class="reference internal" href="../reference/datamodel.html#object.__repr__" title="object.__repr__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__repr__()</span></code></a>, <a class="reference internal" href="../reference/datamodel.html#object.__eq__" title="object.__eq__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__eq__()</span></code></a>, and
<a class="reference internal" href="../reference/datamodel.html#object.__hash__" title="object.__hash__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__hash__()</span></code></a> are generated automatically.</p>
<p>Example:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="nd">@dataclass</span>
<span class="k">class</span> <span class="nc">Point</span><span class="p">:</span>
    <span class="n">x</span><span class="p">:</span> <span class="nb">float</span>
    <span class="n">y</span><span class="p">:</span> <span class="nb">float</span>
    <span class="n">z</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.0</span>

<span class="n">p</span> <span class="o">=</span> <span class="n">Point</span><span class="p">(</span><span class="mf">1.5</span><span class="p">,</span> <span class="mf">2.5</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>   <span class="c1"># produces &quot;Point(x=1.5, y=2.5, z=0.0)&quot;</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><span class="target" id="index-29"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0557"><strong>PEP 557</strong></a> – Data Classes</dt><dd><p>PEP written and implemented by Eric V. Smith</p>
</dd>
</dl>
</div>
</div>
<div class="section" id="importlib-resources">
<span id="whatsnew37-importlib-resources"></span><h3>importlib.resources<a class="headerlink" href="#importlib-resources" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/importlib.html#module-importlib.resources" title="importlib.resources: Package resource reading, opening, and access"><code class="xref py py-mod docutils literal notranslate"><span class="pre">importlib.resources</span></code></a> module provides several new APIs and one
new ABC for access to, opening, and reading <em>resources</em> inside packages.
Resources are roughly similar to files inside packages, but they needn’t
be actual files on the physical file system.  Module loaders can provide a
<code class="xref py py-meth docutils literal notranslate"><span class="pre">get_resource_reader()</span></code> function which returns
a <a class="reference internal" href="../library/importlib.html#importlib.abc.ResourceReader" title="importlib.abc.ResourceReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.abc.ResourceReader</span></code></a> instance to support this
new API.  Built-in file path loaders and zip file loaders both support this.</p>
<p>Contributed by Barry Warsaw and Brett Cannon in <a class="reference external" href="https://bugs.python.org/issue32248">bpo-32248</a>.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference external" href="http://importlib-resources.readthedocs.io/en/latest/">importlib_resources</a>
– a PyPI backport for earlier Python versions.</p>
</div>
</div>
</div>
<div class="section" id="improved-modules">
<h2>Improved Modules<a class="headerlink" href="#improved-modules" title="Permalink to this headline">¶</a></h2>
<div class="section" id="argparse">
<h3>argparse<a class="headerlink" href="#argparse" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/argparse.html#argparse.ArgumentParser.parse_intermixed_args" title="argparse.ArgumentParser.parse_intermixed_args"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ArgumentParser.parse_intermixed_args()</span></code></a>
method allows intermixing options and positional arguments.
(Contributed by paul.j3 in <a class="reference external" href="https://bugs.python.org/issue14191">bpo-14191</a>.)</p>
</div>
<div class="section" id="asyncio">
<span id="whatsnew37-asyncio"></span><h3>asyncio<a class="headerlink" href="#asyncio" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code></a> module has received many new features, usability and
<a class="reference internal" href="#whatsnew37-asyncio-perf"><span class="std std-ref">performance improvements</span></a>.  Notable changes
include:</p>
<ul>
<li><p>The new <a class="reference internal" href="../glossary.html#term-provisional-api"><span class="xref std std-term">provisional</span></a> <a class="reference internal" href="../library/asyncio-task.html#asyncio.run" title="asyncio.run"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.run()</span></code></a> function can
be used to run a coroutine from synchronous code by automatically creating and
destroying the event loop.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue32314">bpo-32314</a>.)</p></li>
<li><p>asyncio gained support for <a class="reference internal" href="../library/contextvars.html#module-contextvars" title="contextvars: Context Variables"><code class="xref py py-mod docutils literal notranslate"><span class="pre">contextvars</span></code></a>.
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.call_soon" title="asyncio.loop.call_soon"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.call_soon()</span></code></a>,
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.call_soon_threadsafe" title="asyncio.loop.call_soon_threadsafe"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.call_soon_threadsafe()</span></code></a>,
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.call_later" title="asyncio.loop.call_later"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.call_later()</span></code></a>,
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.call_at" title="asyncio.loop.call_at"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.call_at()</span></code></a>, and
<a class="reference internal" href="../library/asyncio-future.html#asyncio.Future.add_done_callback" title="asyncio.Future.add_done_callback"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Future.add_done_callback()</span></code></a>
have a new optional keyword-only <em>context</em> parameter.
<a class="reference internal" href="../library/asyncio-task.html#asyncio.Task" title="asyncio.Task"><code class="xref py py-class docutils literal notranslate"><span class="pre">Tasks</span></code></a> now track their context automatically.
See <span class="target" id="index-30"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0567"><strong>PEP 567</strong></a> for more details.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue32436">bpo-32436</a>.)</p></li>
<li><p>The new <a class="reference internal" href="../library/asyncio-task.html#asyncio.create_task" title="asyncio.create_task"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.create_task()</span></code></a> function has been added as a shortcut
to <code class="docutils literal notranslate"><span class="pre">asyncio.get_event_loop().create_task()</span></code>.
(Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue32311">bpo-32311</a>.)</p></li>
<li><p>The new <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.start_tls" title="asyncio.loop.start_tls"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.start_tls()</span></code></a>
method can be used to upgrade an existing connection to TLS.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue23749">bpo-23749</a>.)</p></li>
<li><p>The new <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.sock_recv_into" title="asyncio.loop.sock_recv_into"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.sock_recv_into()</span></code></a>
method allows reading data from a socket directly into a provided buffer making
it possible to reduce data copies.
(Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue31819">bpo-31819</a>.)</p></li>
<li><p>The new <a class="reference internal" href="../library/asyncio-task.html#asyncio.current_task" title="asyncio.current_task"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.current_task()</span></code></a> function returns the currently running
<a class="reference internal" href="../library/asyncio-task.html#asyncio.Task" title="asyncio.Task"><code class="xref py py-class docutils literal notranslate"><span class="pre">Task</span></code></a> instance, and the new <a class="reference internal" href="../library/asyncio-task.html#asyncio.all_tasks" title="asyncio.all_tasks"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.all_tasks()</span></code></a>
function returns a set of all existing <code class="docutils literal notranslate"><span class="pre">Task</span></code> instances in a given loop.
The <a class="reference internal" href="../library/asyncio-task.html#asyncio.Task.current_task" title="asyncio.Task.current_task"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Task.current_task()</span></code></a> and
<a class="reference internal" href="../library/asyncio-task.html#asyncio.Task.all_tasks" title="asyncio.Task.all_tasks"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Task.all_tasks()</span></code></a> methods have been deprecated.
(Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue32250">bpo-32250</a>.)</p></li>
<li><p>The new <em>provisional</em> <a class="reference internal" href="../library/asyncio-protocol.html#asyncio.BufferedProtocol" title="asyncio.BufferedProtocol"><code class="xref py py-class docutils literal notranslate"><span class="pre">BufferedProtocol</span></code></a> class allows
implementing streaming protocols with manual control over the receive buffer.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue32251">bpo-32251</a>.)</p></li>
<li><p>The new <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.get_running_loop" title="asyncio.get_running_loop"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.get_running_loop()</span></code></a> function returns the currently
running loop, and raises a <a class="reference internal" href="../library/exceptions.html#RuntimeError" title="RuntimeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code></a> if no loop is running.
This is in contrast with <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.get_event_loop" title="asyncio.get_event_loop"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.get_event_loop()</span></code></a>, which will <em>create</em>
a new event loop if none is running.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue32269">bpo-32269</a>.)</p></li>
<li><p>The new <a class="reference internal" href="../library/asyncio-stream.html#asyncio.StreamWriter.wait_closed" title="asyncio.StreamWriter.wait_closed"><code class="xref py py-meth docutils literal notranslate"><span class="pre">StreamWriter.wait_closed()</span></code></a>
coroutine method allows waiting until the stream writer is closed.  The new
<a class="reference internal" href="../library/asyncio-stream.html#asyncio.StreamWriter.is_closing" title="asyncio.StreamWriter.is_closing"><code class="xref py py-meth docutils literal notranslate"><span class="pre">StreamWriter.is_closing()</span></code></a> method
can be used to determine if the writer is closing.
(Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue32391">bpo-32391</a>.)</p></li>
<li><p>The new <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.sock_sendfile" title="asyncio.loop.sock_sendfile"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.sock_sendfile()</span></code></a>
coroutine method allows sending files using <a class="reference internal" href="../library/os.html#os.sendfile" title="os.sendfile"><code class="xref py py-mod docutils literal notranslate"><span class="pre">os.sendfile</span></code></a> when possible.
(Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue32410">bpo-32410</a>.)</p></li>
<li><p>The new <a class="reference internal" href="../library/asyncio-future.html#asyncio.Future.get_loop" title="asyncio.Future.get_loop"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Future.get_loop()</span></code></a> and
<code class="docutils literal notranslate"><span class="pre">Task.get_loop()</span></code> methods return the instance of the loop on which a task or
a future were created.
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Server.get_loop" title="asyncio.Server.get_loop"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Server.get_loop()</span></code></a> allows doing the same for
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Server" title="asyncio.Server"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.Server</span></code></a> objects.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue32415">bpo-32415</a> and
Srinivas Reddy Thatiparthy in <a class="reference external" href="https://bugs.python.org/issue32418">bpo-32418</a>.)</p></li>
<li><p>It is now possible to control how instances of <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Server" title="asyncio.Server"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.Server</span></code></a> begin
serving.  Previously, the server would start serving immediately when created.
The new <em>start_serving</em> keyword argument to
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.create_server" title="asyncio.loop.create_server"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.create_server()</span></code></a> and
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.create_unix_server" title="asyncio.loop.create_unix_server"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.create_unix_server()</span></code></a>,
as well as <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Server.start_serving" title="asyncio.Server.start_serving"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Server.start_serving()</span></code></a>, and
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Server.serve_forever" title="asyncio.Server.serve_forever"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Server.serve_forever()</span></code></a>
can be used to decouple server instantiation and serving.  The new
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Server.is_serving" title="asyncio.Server.is_serving"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Server.is_serving()</span></code></a> method returns <code class="docutils literal notranslate"><span class="pre">True</span></code>
if the server is serving.  <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Server" title="asyncio.Server"><code class="xref py py-class docutils literal notranslate"><span class="pre">Server</span></code></a> objects are now
asynchronous context managers:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">srv</span> <span class="o">=</span> <span class="k">await</span> <span class="n">loop</span><span class="o">.</span><span class="n">create_server</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>

<span class="k">async</span> <span class="k">with</span> <span class="n">srv</span><span class="p">:</span>
    <span class="c1"># some code</span>

<span class="c1"># At this point, srv is closed and no longer accepts new connections.</span>
</pre></div>
</div>
<p>(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue32662">bpo-32662</a>.)</p>
</li>
<li><p>Callback objects returned by
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.call_later" title="asyncio.loop.call_later"><code class="xref py py-func docutils literal notranslate"><span class="pre">loop.call_later()</span></code></a>
gained the new <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.TimerHandle.when" title="asyncio.TimerHandle.when"><code class="xref py py-meth docutils literal notranslate"><span class="pre">when()</span></code></a> method which
returns an absolute scheduled callback timestamp.
(Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue32741">bpo-32741</a>.)</p></li>
<li><p>The <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.create_datagram_endpoint" title="asyncio.loop.create_datagram_endpoint"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.create_datagram_endpoint()</span> </code></a> method
gained support for Unix sockets.
(Contributed by Quentin Dawans in <a class="reference external" href="https://bugs.python.org/issue31245">bpo-31245</a>.)</p></li>
<li><p>The <a class="reference internal" href="../library/asyncio-stream.html#asyncio.open_connection" title="asyncio.open_connection"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.open_connection()</span></code></a>, <a class="reference internal" href="../library/asyncio-stream.html#asyncio.start_server" title="asyncio.start_server"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.start_server()</span></code></a> functions,
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.create_connection" title="asyncio.loop.create_connection"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.create_connection()</span></code></a>,
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.create_server" title="asyncio.loop.create_server"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.create_server()</span></code></a>,
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.connect_accepted_socket" title="asyncio.loop.connect_accepted_socket"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.create_accepted_socket()</span></code></a>
methods and their corresponding UNIX socket variants now accept the
<em>ssl_handshake_timeout</em> keyword argument.
(Contributed by Neil Aspinall in <a class="reference external" href="https://bugs.python.org/issue29970">bpo-29970</a>.)</p></li>
<li><p>The new <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Handle.cancelled" title="asyncio.Handle.cancelled"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Handle.cancelled()</span></code></a> method returns
<code class="docutils literal notranslate"><span class="pre">True</span></code> if the callback was cancelled.
(Contributed by Marat Sharafutdinov in <a class="reference external" href="https://bugs.python.org/issue31943">bpo-31943</a>.)</p></li>
<li><p>The asyncio source has been converted to use the
<a class="reference internal" href="../reference/compound_stmts.html#async"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span></code></a>/<a class="reference internal" href="../reference/expressions.html#await"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">await</span></code></a> syntax.
(Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue32193">bpo-32193</a>.)</p></li>
<li><p>The new <a class="reference internal" href="../library/asyncio-protocol.html#asyncio.ReadTransport.is_reading" title="asyncio.ReadTransport.is_reading"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ReadTransport.is_reading()</span></code></a>
method can be used to determine the reading state of the transport.
Additionally, calls to
<a class="reference internal" href="../library/asyncio-protocol.html#asyncio.ReadTransport.resume_reading" title="asyncio.ReadTransport.resume_reading"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ReadTransport.resume_reading()</span></code></a>
and <a class="reference internal" href="../library/asyncio-protocol.html#asyncio.ReadTransport.pause_reading" title="asyncio.ReadTransport.pause_reading"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ReadTransport.pause_reading()</span></code></a>
are now idempotent.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue32356">bpo-32356</a>.)</p></li>
<li><p>Loop methods which accept socket paths now support passing
<a class="reference internal" href="../glossary.html#term-path-like-object"><span class="xref std std-term">path-like objects</span></a>.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue32066">bpo-32066</a>.)</p></li>
<li><p>In <a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code></a> TCP sockets on Linux are now created with <code class="docutils literal notranslate"><span class="pre">TCP_NODELAY</span></code>
flag set by default.
(Contributed by Yury Selivanov and Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue27456">bpo-27456</a>.)</p></li>
<li><p>Exceptions occurring in cancelled tasks are no longer logged.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue30508">bpo-30508</a>.)</p></li>
<li><p>New <code class="docutils literal notranslate"><span class="pre">WindowsSelectorEventLoopPolicy</span></code> and
<code class="docutils literal notranslate"><span class="pre">WindowsProactorEventLoopPolicy</span></code> classes.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue33792">bpo-33792</a>.)</p></li>
</ul>
<p>Several <code class="docutils literal notranslate"><span class="pre">asyncio</span></code> APIs have been
<a class="reference internal" href="#whatsnew37-asyncio-deprecated"><span class="std std-ref">deprecated</span></a>.</p>
</div>
<div class="section" id="binascii">
<h3>binascii<a class="headerlink" href="#binascii" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../library/binascii.html#binascii.b2a_uu" title="binascii.b2a_uu"><code class="xref py py-func docutils literal notranslate"><span class="pre">b2a_uu()</span></code></a> function now accepts an optional <em>backtick</em>
keyword argument.  When it’s true, zeros are represented by <code class="docutils literal notranslate"><span class="pre">'`'</span></code>
instead of spaces.  (Contributed by Xiang Zhang in <a class="reference external" href="https://bugs.python.org/issue30103">bpo-30103</a>.)</p>
</div>
<div class="section" id="calendar">
<h3>calendar<a class="headerlink" href="#calendar" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../library/calendar.html#calendar.HTMLCalendar" title="calendar.HTMLCalendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">HTMLCalendar</span></code></a> class has new class attributes which ease
the customization of CSS classes in the produced HTML calendar.
(Contributed by Oz Tiram in <a class="reference external" href="https://bugs.python.org/issue30095">bpo-30095</a>.)</p>
</div>
<div class="section" id="collections">
<h3>collections<a class="headerlink" href="#collections" title="Permalink to this headline">¶</a></h3>
<p><code class="docutils literal notranslate"><span class="pre">collections.namedtuple()</span></code> now supports default values.
(Contributed by Raymond Hettinger in <a class="reference external" href="https://bugs.python.org/issue32320">bpo-32320</a>.)</p>
</div>
<div class="section" id="compileall">
<h3>compileall<a class="headerlink" href="#compileall" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/compileall.html#compileall.compile_dir" title="compileall.compile_dir"><code class="xref py py-func docutils literal notranslate"><span class="pre">compileall.compile_dir()</span></code></a> learned the new <em>invalidation_mode</em> parameter,
which can be used to enable
<a class="reference internal" href="#whatsnew37-pep552"><span class="std std-ref">hash-based .pyc invalidation</span></a>.  The invalidation
mode can also be specified on the command line using the new
<code class="docutils literal notranslate"><span class="pre">--invalidation-mode</span></code> argument.
(Contributed by Benjamin Peterson in <a class="reference external" href="https://bugs.python.org/issue31650">bpo-31650</a>.)</p>
</div>
<div class="section" id="concurrent-futures">
<h3>concurrent.futures<a class="headerlink" href="#concurrent-futures" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/concurrent.futures.html#concurrent.futures.ProcessPoolExecutor" title="concurrent.futures.ProcessPoolExecutor"><code class="xref py py-class docutils literal notranslate"><span class="pre">ProcessPoolExecutor</span></code></a> and
<a class="reference internal" href="../library/concurrent.futures.html#concurrent.futures.ThreadPoolExecutor" title="concurrent.futures.ThreadPoolExecutor"><code class="xref py py-class docutils literal notranslate"><span class="pre">ThreadPoolExecutor</span></code></a> now
support the new <em>initializer</em> and <em>initargs</em> constructor arguments.
(Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue21423">bpo-21423</a>.)</p>
<p>The <a class="reference internal" href="../library/concurrent.futures.html#concurrent.futures.ProcessPoolExecutor" title="concurrent.futures.ProcessPoolExecutor"><code class="xref py py-class docutils literal notranslate"><span class="pre">ProcessPoolExecutor</span></code></a>
can now take the multiprocessing context via the new <em>mp_context</em> argument.
(Contributed by Thomas Moreau in <a class="reference external" href="https://bugs.python.org/issue31540">bpo-31540</a>.)</p>
</div>
<div class="section" id="contextlib">
<h3>contextlib<a class="headerlink" href="#contextlib" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/contextlib.html#contextlib.nullcontext" title="contextlib.nullcontext"><code class="xref py py-func docutils literal notranslate"><span class="pre">nullcontext()</span></code></a> is a simpler and faster no-op
context manager than <a class="reference internal" href="../library/contextlib.html#contextlib.ExitStack" title="contextlib.ExitStack"><code class="xref py py-class docutils literal notranslate"><span class="pre">ExitStack</span></code></a>.
(Contributed by Jesse-Bakker in <a class="reference external" href="https://bugs.python.org/issue10049">bpo-10049</a>.)</p>
<p>The new <a class="reference internal" href="../library/contextlib.html#contextlib.asynccontextmanager" title="contextlib.asynccontextmanager"><code class="xref py py-func docutils literal notranslate"><span class="pre">asynccontextmanager()</span></code></a>,
<a class="reference internal" href="../library/contextlib.html#contextlib.AbstractAsyncContextManager" title="contextlib.AbstractAsyncContextManager"><code class="xref py py-class docutils literal notranslate"><span class="pre">AbstractAsyncContextManager</span></code></a>, and
<a class="reference internal" href="../library/contextlib.html#contextlib.AsyncExitStack" title="contextlib.AsyncExitStack"><code class="xref py py-class docutils literal notranslate"><span class="pre">AsyncExitStack</span></code></a> have been added to
complement their synchronous counterparts.  (Contributed
by Jelle Zijlstra in <a class="reference external" href="https://bugs.python.org/issue29679">bpo-29679</a> and <a class="reference external" href="https://bugs.python.org/issue30241">bpo-30241</a>,
and by Alexander Mohr and Ilya Kulakov in <a class="reference external" href="https://bugs.python.org/issue29302">bpo-29302</a>.)</p>
</div>
<div class="section" id="cprofile">
<h3>cProfile<a class="headerlink" href="#cprofile" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../library/profile.html#module-cProfile" title="cProfile"><code class="xref py py-mod docutils literal notranslate"><span class="pre">cProfile</span></code></a> command line now accepts <code class="docutils literal notranslate"><span class="pre">-m</span> <span class="pre">module_name</span></code> as an
alternative to script path.  (Contributed by Sanyam Khurana in <a class="reference external" href="https://bugs.python.org/issue21862">bpo-21862</a>.)</p>
</div>
<div class="section" id="crypt">
<h3>crypt<a class="headerlink" href="#crypt" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../library/crypt.html#module-crypt" title="crypt: The crypt() function used to check Unix passwords. (Unix)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">crypt</span></code></a> module now supports the Blowfish hashing method.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue31664">bpo-31664</a>.)</p>
<p>The <a class="reference internal" href="../library/crypt.html#crypt.mksalt" title="crypt.mksalt"><code class="xref py py-func docutils literal notranslate"><span class="pre">mksalt()</span></code></a> function now allows specifying the number of rounds
for hashing.  (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue31702">bpo-31702</a>.)</p>
</div>
<div class="section" id="datetime">
<h3>datetime<a class="headerlink" href="#datetime" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/datetime.html#datetime.datetime.fromisoformat" title="datetime.datetime.fromisoformat"><code class="xref py py-meth docutils literal notranslate"><span class="pre">datetime.fromisoformat()</span></code></a>
method constructs a <a class="reference internal" href="../library/datetime.html#datetime.datetime" title="datetime.datetime"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime</span></code></a> object from a string
in one of the formats output by
<a class="reference internal" href="../library/datetime.html#datetime.datetime.isoformat" title="datetime.datetime.isoformat"><code class="xref py py-meth docutils literal notranslate"><span class="pre">datetime.isoformat()</span></code></a>.
(Contributed by Paul Ganssle in <a class="reference external" href="https://bugs.python.org/issue15873">bpo-15873</a>.)</p>
<p>The <a class="reference internal" href="../library/datetime.html#datetime.tzinfo" title="datetime.tzinfo"><code class="xref py py-class docutils literal notranslate"><span class="pre">tzinfo</span></code></a> class now supports sub-minute offsets.
(Contributed by Alexander Belopolsky in <a class="reference external" href="https://bugs.python.org/issue5288">bpo-5288</a>.)</p>
</div>
<div class="section" id="dbm">
<h3>dbm<a class="headerlink" href="#dbm" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/dbm.html#module-dbm.dumb" title="dbm.dumb: Portable implementation of the simple DBM interface."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dbm.dumb</span></code></a> now supports reading read-only files and no longer writes the
index file when it is not changed.</p>
</div>
<div class="section" id="decimal">
<h3>decimal<a class="headerlink" href="#decimal" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../library/decimal.html#module-decimal" title="decimal: Implementation of the General Decimal Arithmetic  Specification."><code class="xref py py-mod docutils literal notranslate"><span class="pre">decimal</span></code></a> module now uses <a class="reference internal" href="#whatsnew37-pep567"><span class="std std-ref">context variables</span></a>
to store the decimal context.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue32630">bpo-32630</a>.)</p>
</div>
<div class="section" id="dis">
<h3>dis<a class="headerlink" href="#dis" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../library/dis.html#dis.dis" title="dis.dis"><code class="xref py py-func docutils literal notranslate"><span class="pre">dis()</span></code></a> function is now able to
disassemble nested code objects (the code of comprehensions, generator
expressions and nested functions, and the code used for building nested
classes).  The maximum depth of disassembly recursion is controlled by
the new <em>depth</em> parameter.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue11822">bpo-11822</a>.)</p>
</div>
<div class="section" id="distutils">
<h3>distutils<a class="headerlink" href="#distutils" title="Permalink to this headline">¶</a></h3>
<p><code class="docutils literal notranslate"><span class="pre">README.rst</span></code> is now included in the list of distutils standard READMEs and
therefore included in source distributions.
(Contributed by Ryan Gonzalez in <a class="reference external" href="https://bugs.python.org/issue11913">bpo-11913</a>.)</p>
</div>
<div class="section" id="enum">
<h3>enum<a class="headerlink" href="#enum" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../library/enum.html#enum.Enum" title="enum.Enum"><code class="xref py py-class docutils literal notranslate"><span class="pre">Enum</span></code></a> learned the new <code class="docutils literal notranslate"><span class="pre">_ignore_</span></code> class property,
which allows listing the names of properties which should not become
enum members.
(Contributed by Ethan Furman in <a class="reference external" href="https://bugs.python.org/issue31801">bpo-31801</a>.)</p>
<p>In Python 3.8, attempting to check for non-Enum objects in <code class="xref py py-class docutils literal notranslate"><span class="pre">Enum</span></code>
classes will raise a <a class="reference internal" href="../library/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> (e.g. <code class="docutils literal notranslate"><span class="pre">1</span> <span class="pre">in</span> <span class="pre">Color</span></code>); similarly,
attempting to check for non-Flag objects in a <code class="xref py py-class docutils literal notranslate"><span class="pre">Flag</span></code> member will
raise <a class="reference internal" href="../library/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> (e.g. <code class="docutils literal notranslate"><span class="pre">1</span> <span class="pre">in</span> <span class="pre">Perm.RW</span></code>); currently, both operations
return <a class="reference internal" href="../library/constants.html#False" title="False"><code class="xref py py-const docutils literal notranslate"><span class="pre">False</span></code></a> instead and are deprecated.
(Contributed by Ethan Furman in <a class="reference external" href="https://bugs.python.org/issue33217">bpo-33217</a>.)</p>
</div>
<div class="section" id="functools">
<h3>functools<a class="headerlink" href="#functools" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/functools.html#functools.singledispatch" title="functools.singledispatch"><code class="xref py py-func docutils literal notranslate"><span class="pre">functools.singledispatch()</span></code></a> now supports registering implementations
using type annotations.
(Contributed by Łukasz Langa in <a class="reference external" href="https://bugs.python.org/issue32227">bpo-32227</a>.)</p>
</div>
<div class="section" id="gc">
<h3>gc<a class="headerlink" href="#gc" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/gc.html#gc.freeze" title="gc.freeze"><code class="xref py py-func docutils literal notranslate"><span class="pre">gc.freeze()</span></code></a> function allows freezing all objects tracked
by the garbage collector and excluding them from future collections.
This can be used before a POSIX <code class="docutils literal notranslate"><span class="pre">fork()</span></code> call to make the GC copy-on-write
friendly or to speed up collection.  The new <a class="reference internal" href="../library/gc.html#gc.unfreeze" title="gc.unfreeze"><code class="xref py py-func docutils literal notranslate"><span class="pre">gc.unfreeze()</span></code></a> functions
reverses this operation.  Additionally, <a class="reference internal" href="../library/gc.html#gc.get_freeze_count" title="gc.get_freeze_count"><code class="xref py py-func docutils literal notranslate"><span class="pre">gc.get_freeze_count()</span></code></a> can
be used to obtain the number of frozen objects.
(Contributed by Li Zekun in <a class="reference external" href="https://bugs.python.org/issue31558">bpo-31558</a>.)</p>
</div>
<div class="section" id="hmac">
<h3>hmac<a class="headerlink" href="#hmac" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../library/hmac.html#module-hmac" title="hmac: Keyed-Hashing for Message Authentication (HMAC) implementation"><code class="xref py py-mod docutils literal notranslate"><span class="pre">hmac</span></code></a> module now has an optimized one-shot <a class="reference internal" href="../library/hmac.html#hmac.digest" title="hmac.digest"><code class="xref py py-func docutils literal notranslate"><span class="pre">digest()</span></code></a>
function, which is up to three times faster than <code class="xref py py-func docutils literal notranslate"><span class="pre">HMAC()</span></code>.
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue32433">bpo-32433</a>.)</p>
</div>
<div class="section" id="http-client">
<h3>http.client<a class="headerlink" href="#http-client" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/http.client.html#http.client.HTTPConnection" title="http.client.HTTPConnection"><code class="xref py py-class docutils literal notranslate"><span class="pre">HTTPConnection</span></code></a> and <a class="reference internal" href="../library/http.client.html#http.client.HTTPSConnection" title="http.client.HTTPSConnection"><code class="xref py py-class docutils literal notranslate"><span class="pre">HTTPSConnection</span></code></a>
now support the new <em>blocksize</em> argument for improved upload throughput.
(Contributed by Nir Soffer in <a class="reference external" href="https://bugs.python.org/issue31945">bpo-31945</a>.)</p>
</div>
<div class="section" id="http-server">
<h3>http.server<a class="headerlink" href="#http-server" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/http.server.html#http.server.SimpleHTTPRequestHandler" title="http.server.SimpleHTTPRequestHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">SimpleHTTPRequestHandler</span></code></a> now supports the HTTP
<code class="docutils literal notranslate"><span class="pre">If-Modified-Since</span></code> header.  The server returns the 304 response status if
the target file was not modified after the time specified in the header.
(Contributed by Pierre Quentel in <a class="reference external" href="https://bugs.python.org/issue29654">bpo-29654</a>.)</p>
<p><a class="reference internal" href="../library/http.server.html#http.server.SimpleHTTPRequestHandler" title="http.server.SimpleHTTPRequestHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">SimpleHTTPRequestHandler</span></code></a> accepts the new <em>directory</em>
argument, in addition to the new <code class="docutils literal notranslate"><span class="pre">--directory</span></code> command line argument.
With this parameter, the server serves the specified directory, by default it
uses the current working directory.
(Contributed by Stéphane Wirtel and Julien Palard in <a class="reference external" href="https://bugs.python.org/issue28707">bpo-28707</a>.)</p>
<p>The new <a class="reference internal" href="../library/http.server.html#http.server.ThreadingHTTPServer" title="http.server.ThreadingHTTPServer"><code class="xref py py-class docutils literal notranslate"><span class="pre">ThreadingHTTPServer</span></code></a> class
uses threads to handle requests using <code class="xref py py-class docutils literal notranslate"><span class="pre">ThreadingMixin</span></code>.
It is used when <code class="docutils literal notranslate"><span class="pre">http.server</span></code> is run with <code class="docutils literal notranslate"><span class="pre">-m</span></code>.
(Contributed by Julien Palard in <a class="reference external" href="https://bugs.python.org/issue31639">bpo-31639</a>.)</p>
</div>
<div class="section" id="idlelib-and-idle">
<h3>idlelib and IDLE<a class="headerlink" href="#idlelib-and-idle" title="Permalink to this headline">¶</a></h3>
<p>Multiple fixes for autocompletion. (Contributed by Louie Lu in <a class="reference external" href="https://bugs.python.org/issue15786">bpo-15786</a>.)</p>
<p>Module Browser (on the File menu, formerly called Class Browser),
now displays nested functions and classes in addition to top-level
functions and classes.
(Contributed by Guilherme Polo, Cheryl Sabella, and Terry Jan Reedy
in <a class="reference external" href="https://bugs.python.org/issue1612262">bpo-1612262</a>.)</p>
<p>The Settings dialog (Options, Configure IDLE) has been partly rewritten
to improve both appearance and function.
(Contributed by Cheryl Sabella and Terry Jan Reedy in multiple issues.)</p>
<p>The font sample now includes a selection of non-Latin characters so that
users can better see the effect of selecting a particular font.
(Contributed by Terry Jan Reedy in <a class="reference external" href="https://bugs.python.org/issue13802">bpo-13802</a>.)
The sample can be edited to include other characters.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue31860">bpo-31860</a>.)</p>
<p>The IDLE features formerly implemented as extensions have been reimplemented
as normal features.  Their settings have been moved from the Extensions tab
to other dialog tabs.
(Contributed by Charles Wohlganger and Terry Jan Reedy in <a class="reference external" href="https://bugs.python.org/issue27099">bpo-27099</a>.)</p>
<p>Editor code context option revised.  Box displays all context lines up to
maxlines.  Clicking on a context line jumps the editor to that line.  Context
colors for custom themes is added to Highlights tab of Settings dialog.
(Contributed by Cheryl Sabella and Terry Jan Reedy in <a class="reference external" href="https://bugs.python.org/issue33642">bpo-33642</a>,
<a class="reference external" href="https://bugs.python.org/issue33768">bpo-33768</a>, and <a class="reference external" href="https://bugs.python.org/issue33679">bpo-33679</a>.)</p>
<p>On Windows, a new API call tells Windows that tk scales for DPI. On Windows
8.1+ or 10, with DPI compatibility properties of the Python binary
unchanged, and a monitor resolution greater than 96 DPI, this should
make text and lines sharper.  It should otherwise have no effect.
(Contributed by Terry Jan Reedy in <a class="reference external" href="https://bugs.python.org/issue33656">bpo-33656</a>.)</p>
<p>New in 3.7.1:</p>
<p>Output over N lines (50 by default) is squeezed down to a button.
N can be changed in the PyShell section of the General page of the
Settings dialog.  Fewer, but possibly extra long, lines can be squeezed by
right clicking on the output.  Squeezed output can be expanded in place
by double-clicking the button or into the clipboard or a separate window
by right-clicking the button.  (Contributed by Tal Einat in <a class="reference external" href="https://bugs.python.org/issue1529353">bpo-1529353</a>.)</p>
<p>The changes above have been backported to 3.6 maintenance releases.</p>
<p>NEW in 3.7.4:</p>
<p>Add “Run Customized” to the Run menu to run a module with customized
settings. Any command line arguments entered are added to sys.argv.
They re-appear in the box for the next customized run.  One can also
suppress the normal Shell main module restart.  (Contributed by Cheryl
Sabella, Terry Jan Reedy, and others in <a class="reference external" href="https://bugs.python.org/issue5680">bpo-5680</a> and <a class="reference external" href="https://bugs.python.org/issue37627">bpo-37627</a>.)</p>
<p>New in 3.7.5:</p>
<p>Add optional line numbers for IDLE editor windows. Windows
open without line numbers unless set otherwise in the General
tab of the configuration dialog.  Line numbers for an existing
window are shown and hidden in the Options menu.
(Contributed by Tal Einat and Saimadhav Heblikar in <a class="reference external" href="https://bugs.python.org/issue17535">bpo-17535</a>.)</p>
</div>
<div class="section" id="importlib">
<h3>importlib<a class="headerlink" href="#importlib" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../library/importlib.html#importlib.abc.ResourceReader" title="importlib.abc.ResourceReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.abc.ResourceReader</span></code></a> ABC was introduced to
support the loading of resources from packages.  See also
<a class="reference internal" href="#whatsnew37-importlib-resources"><span class="std std-ref">importlib.resources</span></a>.
(Contributed by Barry Warsaw, Brett Cannon in <a class="reference external" href="https://bugs.python.org/issue32248">bpo-32248</a>.)</p>
<p><a class="reference internal" href="../library/importlib.html#importlib.reload" title="importlib.reload"><code class="xref py py-func docutils literal notranslate"><span class="pre">importlib.reload()</span></code></a> now raises <a class="reference internal" href="../library/exceptions.html#ModuleNotFoundError" title="ModuleNotFoundError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ModuleNotFoundError</span></code></a> if the module
lacks a spec.
(Contributed by Garvit Khatri in <a class="reference external" href="https://bugs.python.org/issue29851">bpo-29851</a>.)</p>
<p><code class="xref py py-func docutils literal notranslate"><span class="pre">importlib.find_spec()</span></code> now raises <a class="reference internal" href="../library/exceptions.html#ModuleNotFoundError" title="ModuleNotFoundError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ModuleNotFoundError</span></code></a> instead of
<a class="reference internal" href="../library/exceptions.html#AttributeError" title="AttributeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">AttributeError</span></code></a> if the specified parent module is not a package (i.e.
lacks a <code class="docutils literal notranslate"><span class="pre">__path__</span></code> attribute).
(Contributed by Milan Oberkirch in <a class="reference external" href="https://bugs.python.org/issue30436">bpo-30436</a>.)</p>
<p>The new <code class="xref py py-func docutils literal notranslate"><span class="pre">importlib.source_hash()</span></code> can be used to compute the hash of
the passed source.  A <a class="reference internal" href="#whatsnew37-pep552"><span class="std std-ref">hash-based .pyc file</span></a>
embeds the value returned by this function.</p>
</div>
<div class="section" id="io">
<h3>io<a class="headerlink" href="#io" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/io.html#io.TextIOWrapper.reconfigure" title="io.TextIOWrapper.reconfigure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">TextIOWrapper.reconfigure()</span></code></a>
method can be used to reconfigure the text stream with the new settings.
(Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue30526">bpo-30526</a> and
INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue15216">bpo-15216</a>.)</p>
</div>
<div class="section" id="ipaddress">
<h3>ipaddress<a class="headerlink" href="#ipaddress" title="Permalink to this headline">¶</a></h3>
<p>The new <code class="docutils literal notranslate"><span class="pre">subnet_of()</span></code> and <code class="docutils literal notranslate"><span class="pre">supernet_of()</span></code> methods of
<a class="reference internal" href="../library/ipaddress.html#ipaddress.IPv6Network" title="ipaddress.IPv6Network"><code class="xref py py-class docutils literal notranslate"><span class="pre">ipaddress.IPv6Network</span></code></a> and <a class="reference internal" href="../library/ipaddress.html#ipaddress.IPv4Network" title="ipaddress.IPv4Network"><code class="xref py py-class docutils literal notranslate"><span class="pre">ipaddress.IPv4Network</span></code></a> can
be used for network containment tests.
(Contributed by Michel Albert and Cheryl Sabella in <a class="reference external" href="https://bugs.python.org/issue20825">bpo-20825</a>.)</p>
</div>
<div class="section" id="itertools">
<h3>itertools<a class="headerlink" href="#itertools" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/itertools.html#itertools.islice" title="itertools.islice"><code class="xref py py-func docutils literal notranslate"><span class="pre">itertools.islice()</span></code></a> now accepts
<a class="reference internal" href="../reference/datamodel.html#object.__index__" title="object.__index__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">integer-like</span> <span class="pre">objects</span></code></a> as start, stop,
and slice arguments.
(Contributed by Will Roberts in <a class="reference external" href="https://bugs.python.org/issue30537">bpo-30537</a>.)</p>
</div>
<div class="section" id="locale">
<h3>locale<a class="headerlink" href="#locale" title="Permalink to this headline">¶</a></h3>
<p>The new <em>monetary</em> argument to <a class="reference internal" href="../library/locale.html#locale.format_string" title="locale.format_string"><code class="xref py py-func docutils literal notranslate"><span class="pre">locale.format_string()</span></code></a> can be used
to make the conversion use monetary thousands separators and
grouping strings.  (Contributed by Garvit in <a class="reference external" href="https://bugs.python.org/issue10379">bpo-10379</a>.)</p>
<p>The <a class="reference internal" href="../library/locale.html#locale.getpreferredencoding" title="locale.getpreferredencoding"><code class="xref py py-func docutils literal notranslate"><span class="pre">locale.getpreferredencoding()</span></code></a> function now always returns <code class="docutils literal notranslate"><span class="pre">'UTF-8'</span></code>
on Android or when in the <a class="reference internal" href="#whatsnew37-pep540"><span class="std std-ref">forced UTF-8 mode</span></a>.</p>
</div>
<div class="section" id="logging">
<h3>logging<a class="headerlink" href="#logging" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/logging.html#logging.Logger" title="logging.Logger"><code class="xref py py-class docutils literal notranslate"><span class="pre">Logger</span></code></a> instances can now be pickled.
(Contributed by Vinay Sajip in <a class="reference external" href="https://bugs.python.org/issue30520">bpo-30520</a>.)</p>
<p>The new <a class="reference internal" href="../library/logging.handlers.html#logging.StreamHandler.setStream" title="logging.StreamHandler.setStream"><code class="xref py py-meth docutils literal notranslate"><span class="pre">StreamHandler.setStream()</span></code></a>
method can be used to replace the logger stream after handler creation.
(Contributed by Vinay Sajip in <a class="reference external" href="https://bugs.python.org/issue30522">bpo-30522</a>.)</p>
<p>It is now possible to specify keyword arguments to handler constructors in
configuration passed to <a class="reference internal" href="../library/logging.config.html#logging.config.fileConfig" title="logging.config.fileConfig"><code class="xref py py-func docutils literal notranslate"><span class="pre">logging.config.fileConfig()</span></code></a>.
(Contributed by Preston Landers in <a class="reference external" href="https://bugs.python.org/issue31080">bpo-31080</a>.)</p>
</div>
<div class="section" id="math">
<h3>math<a class="headerlink" href="#math" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/math.html#math.remainder" title="math.remainder"><code class="xref py py-func docutils literal notranslate"><span class="pre">math.remainder()</span></code></a> function implements the IEEE 754-style remainder
operation.  (Contributed by Mark Dickinson in <a class="reference external" href="https://bugs.python.org/issue29962">bpo-29962</a>.)</p>
</div>
<div class="section" id="mimetypes">
<h3>mimetypes<a class="headerlink" href="#mimetypes" title="Permalink to this headline">¶</a></h3>
<p>The MIME type of .bmp has been changed from <code class="docutils literal notranslate"><span class="pre">'image/x-ms-bmp'</span></code> to
<code class="docutils literal notranslate"><span class="pre">'image/bmp'</span></code>.
(Contributed by Nitish Chandra in <a class="reference external" href="https://bugs.python.org/issue22589">bpo-22589</a>.)</p>
</div>
<div class="section" id="msilib">
<h3>msilib<a class="headerlink" href="#msilib" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/msilib.html#msilib.Database.Close" title="msilib.Database.Close"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Database.Close()</span></code></a> method can be used
to close the <abbr title="last-in, first-out">MSI</abbr> database.
(Contributed by Berker Peksag in <a class="reference external" href="https://bugs.python.org/issue20486">bpo-20486</a>.)</p>
</div>
<div class="section" id="multiprocessing">
<h3>multiprocessing<a class="headerlink" href="#multiprocessing" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/multiprocessing.html#multiprocessing.Process.close" title="multiprocessing.Process.close"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Process.close()</span></code></a> method
explicitly closes the process object and releases all resources associated
with it.  <a class="reference internal" href="../library/exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> is raised if the underlying process is still
running.
(Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue30596">bpo-30596</a>.)</p>
<p>The new <a class="reference internal" href="../library/multiprocessing.html#multiprocessing.Process.kill" title="multiprocessing.Process.kill"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Process.kill()</span></code></a> method can
be used to terminate the process using the <code class="xref py py-data docutils literal notranslate"><span class="pre">SIGKILL</span></code> signal on Unix.
(Contributed by Vitor Pereira in <a class="reference external" href="https://bugs.python.org/issue30794">bpo-30794</a>.)</p>
<p>Non-daemonic threads created by <a class="reference internal" href="../library/multiprocessing.html#multiprocessing.Process" title="multiprocessing.Process"><code class="xref py py-class docutils literal notranslate"><span class="pre">Process</span></code></a> are now
joined on process exit.
(Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue18966">bpo-18966</a>.)</p>
</div>
<div class="section" id="os">
<h3>os<a class="headerlink" href="#os" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/os.html#os.fwalk" title="os.fwalk"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.fwalk()</span></code></a> now accepts the <em>path</em> argument as <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a>.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue28682">bpo-28682</a>.)</p>
<p><a class="reference internal" href="../library/os.html#os.scandir" title="os.scandir"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.scandir()</span></code></a> gained support for <a class="reference internal" href="../library/os.html#path-fd"><span class="std std-ref">file descriptors</span></a>.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue25996">bpo-25996</a>.)</p>
<p>The new <a class="reference internal" href="../library/os.html#os.register_at_fork" title="os.register_at_fork"><code class="xref py py-func docutils literal notranslate"><span class="pre">register_at_fork()</span></code></a> function allows registering Python
callbacks to be executed at process fork.
(Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue16500">bpo-16500</a>.)</p>
<p>Added <a class="reference internal" href="../library/os.html#os.preadv" title="os.preadv"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.preadv()</span></code></a> (combine the functionality of <a class="reference internal" href="../library/os.html#os.readv" title="os.readv"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.readv()</span></code></a> and
<a class="reference internal" href="../library/os.html#os.pread" title="os.pread"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.pread()</span></code></a>) and <a class="reference internal" href="../library/os.html#os.pwritev" title="os.pwritev"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.pwritev()</span></code></a> functions (combine the functionality
of <a class="reference internal" href="../library/os.html#os.writev" title="os.writev"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.writev()</span></code></a> and <a class="reference internal" href="../library/os.html#os.pwrite" title="os.pwrite"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.pwrite()</span></code></a>). (Contributed by Pablo Galindo in
<a class="reference external" href="https://bugs.python.org/issue31368">bpo-31368</a>.)</p>
<p>The mode argument of <a class="reference internal" href="../library/os.html#os.makedirs" title="os.makedirs"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.makedirs()</span></code></a> no longer affects the file
permission bits of newly-created intermediate-level directories.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue19930">bpo-19930</a>.)</p>
<p><a class="reference internal" href="../library/os.html#os.dup2" title="os.dup2"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.dup2()</span></code></a> now returns the new file descriptor.  Previously, <code class="docutils literal notranslate"><span class="pre">None</span></code>
was always returned.
(Contributed by Benjamin Peterson in <a class="reference external" href="https://bugs.python.org/issue32441">bpo-32441</a>.)</p>
<p>The structure returned by <a class="reference internal" href="../library/os.html#os.stat" title="os.stat"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.stat()</span></code></a> now contains the
<a class="reference internal" href="../library/os.html#os.stat_result.st_fstype" title="os.stat_result.st_fstype"><code class="xref py py-attr docutils literal notranslate"><span class="pre">st_fstype</span></code></a> attribute on Solaris and its derivatives.
(Contributed by Jesús Cea Avión in <a class="reference external" href="https://bugs.python.org/issue32659">bpo-32659</a>.)</p>
</div>
<div class="section" id="pathlib">
<h3>pathlib<a class="headerlink" href="#pathlib" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/pathlib.html#pathlib.Path.is_mount" title="pathlib.Path.is_mount"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Path.is_mount()</span></code></a> method is now available
on POSIX systems and can be used to determine whether a path is a mount point.
(Contributed by Cooper Ry Lees in <a class="reference external" href="https://bugs.python.org/issue30897">bpo-30897</a>.)</p>
</div>
<div class="section" id="pdb">
<h3>pdb<a class="headerlink" href="#pdb" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/pdb.html#pdb.set_trace" title="pdb.set_trace"><code class="xref py py-func docutils literal notranslate"><span class="pre">pdb.set_trace()</span></code></a> now takes an optional <em>header</em> keyword-only
argument.  If given, it is printed to the console just before debugging
begins.  (Contributed by Barry Warsaw in <a class="reference external" href="https://bugs.python.org/issue31389">bpo-31389</a>.)</p>
<p><a class="reference internal" href="../library/pdb.html#module-pdb" title="pdb: The Python debugger for interactive interpreters."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pdb</span></code></a> command line now accepts <code class="docutils literal notranslate"><span class="pre">-m</span> <span class="pre">module_name</span></code> as an alternative to
script file.  (Contributed by Mario Corchero in <a class="reference external" href="https://bugs.python.org/issue32206">bpo-32206</a>.)</p>
</div>
<div class="section" id="py-compile">
<h3>py_compile<a class="headerlink" href="#py-compile" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/py_compile.html#py_compile.compile" title="py_compile.compile"><code class="xref py py-func docutils literal notranslate"><span class="pre">py_compile.compile()</span></code></a> – and by extension, <a class="reference internal" href="../library/compileall.html#module-compileall" title="compileall: Tools for byte-compiling all Python source files in a directory tree."><code class="xref py py-mod docutils literal notranslate"><span class="pre">compileall</span></code></a> – now
respects the <span class="target" id="index-31"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">SOURCE_DATE_EPOCH</span></code> environment variable by
unconditionally creating <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files for hash-based validation.
This allows for guaranteeing
<a class="reference external" href="https://reproducible-builds.org/">reproducible builds</a> of <code class="docutils literal notranslate"><span class="pre">.pyc</span></code>
files when they are created eagerly. (Contributed by Bernhard M. Wiedemann
in <a class="reference external" href="https://bugs.python.org/issue29708">bpo-29708</a>.)</p>
</div>
<div class="section" id="pydoc">
<h3>pydoc<a class="headerlink" href="#pydoc" title="Permalink to this headline">¶</a></h3>
<p>The pydoc server can now bind to an arbitrary hostname specified by the
new <code class="docutils literal notranslate"><span class="pre">-n</span></code> command-line argument.
(Contributed by Feanil Patel in <a class="reference external" href="https://bugs.python.org/issue31128">bpo-31128</a>.)</p>
</div>
<div class="section" id="queue">
<h3>queue<a class="headerlink" href="#queue" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/queue.html#queue.SimpleQueue" title="queue.SimpleQueue"><code class="xref py py-class docutils literal notranslate"><span class="pre">SimpleQueue</span></code></a> class is an unbounded <abbr title="last-in, first-out">FIFO</abbr> queue.
(Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue14976">bpo-14976</a>.)</p>
</div>
<div class="section" id="re">
<h3>re<a class="headerlink" href="#re" title="Permalink to this headline">¶</a></h3>
<p>The flags <a class="reference internal" href="../library/re.html#re.ASCII" title="re.ASCII"><code class="xref py py-const docutils literal notranslate"><span class="pre">re.ASCII</span></code></a>, <a class="reference internal" href="../library/re.html#re.LOCALE" title="re.LOCALE"><code class="xref py py-const docutils literal notranslate"><span class="pre">re.LOCALE</span></code></a> and <code class="xref py py-const docutils literal notranslate"><span class="pre">re.UNICODE</span></code>
can be set within the scope of a group.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue31690">bpo-31690</a>.)</p>
<p><a class="reference internal" href="../library/re.html#re.split" title="re.split"><code class="xref py py-func docutils literal notranslate"><span class="pre">re.split()</span></code></a> now supports splitting on a pattern like <code class="docutils literal notranslate"><span class="pre">r'\b'</span></code>,
<code class="docutils literal notranslate"><span class="pre">'^$'</span></code> or <code class="docutils literal notranslate"><span class="pre">(?=-)</span></code> that matches an empty string.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue25054">bpo-25054</a>.)</p>
<p>Regular expressions compiled with the <a class="reference internal" href="../library/re.html#re.LOCALE" title="re.LOCALE"><code class="xref py py-const docutils literal notranslate"><span class="pre">re.LOCALE</span></code></a> flag no longer
depend on the locale at compile time.  Locale settings are applied only
when the compiled regular expression is used.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue30215">bpo-30215</a>.)</p>
<p><a class="reference internal" href="../library/exceptions.html#FutureWarning" title="FutureWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FutureWarning</span></code></a> is now emitted if a regular expression contains
character set constructs that will change semantically in the future,
such as nested sets and set operations.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue30349">bpo-30349</a>.)</p>
<p>Compiled regular expression and match objects can now be copied
using <a class="reference internal" href="../library/copy.html#copy.copy" title="copy.copy"><code class="xref py py-func docutils literal notranslate"><span class="pre">copy.copy()</span></code></a> and <a class="reference internal" href="../library/copy.html#copy.deepcopy" title="copy.deepcopy"><code class="xref py py-func docutils literal notranslate"><span class="pre">copy.deepcopy()</span></code></a>.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue10076">bpo-10076</a>.)</p>
</div>
<div class="section" id="signal">
<h3>signal<a class="headerlink" href="#signal" title="Permalink to this headline">¶</a></h3>
<p>The new <em>warn_on_full_buffer</em> argument to the <a class="reference internal" href="../library/signal.html#signal.set_wakeup_fd" title="signal.set_wakeup_fd"><code class="xref py py-func docutils literal notranslate"><span class="pre">signal.set_wakeup_fd()</span></code></a>
function makes it possible to specify whether Python prints a warning on
stderr when the wakeup buffer overflows.
(Contributed by Nathaniel J. Smith in <a class="reference external" href="https://bugs.python.org/issue30050">bpo-30050</a>.)</p>
</div>
<div class="section" id="socket">
<h3>socket<a class="headerlink" href="#socket" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/socket.html#socket.socket.getblocking" title="socket.socket.getblocking"><code class="xref py py-func docutils literal notranslate"><span class="pre">socket.getblocking()</span></code></a> method
returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if the socket is in blocking mode and <code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue32373">bpo-32373</a>.)</p>
<p>The new <a class="reference internal" href="../library/socket.html#socket.close" title="socket.close"><code class="xref py py-func docutils literal notranslate"><span class="pre">socket.close()</span></code></a> function closes the passed socket file descriptor.
This function should be used instead of <a class="reference internal" href="../library/os.html#os.close" title="os.close"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.close()</span></code></a> for better
compatibility across platforms.
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue32454">bpo-32454</a>.)</p>
<p>The <a class="reference internal" href="../library/socket.html#module-socket" title="socket: Low-level networking interface."><code class="xref py py-mod docutils literal notranslate"><span class="pre">socket</span></code></a> module now exposes the <code class="xref py py-data docutils literal notranslate"><span class="pre">socket.TCP_CONGESTION</span></code>
(Linux 2.6.13), <code class="xref py py-data docutils literal notranslate"><span class="pre">socket.TCP_USER_TIMEOUT</span></code> (Linux 2.6.37), and
<code class="xref py py-data docutils literal notranslate"><span class="pre">socket.TCP_NOTSENT_LOWAT</span></code> (Linux 3.12) constants.
(Contributed by Omar Sandoval in <a class="reference external" href="https://bugs.python.org/issue26273">bpo-26273</a> and
Nathaniel J. Smith in <a class="reference external" href="https://bugs.python.org/issue29728">bpo-29728</a>.)</p>
<p>Support for <a class="reference internal" href="../library/socket.html#socket.AF_VSOCK" title="socket.AF_VSOCK"><code class="xref py py-data docutils literal notranslate"><span class="pre">socket.AF_VSOCK</span></code></a> sockets has been added to allow
communication between virtual machines and their hosts.
(Contributed by Cathy Avery in <a class="reference external" href="https://bugs.python.org/issue27584">bpo-27584</a>.)</p>
<p>Sockets now auto-detect family, type and protocol from file descriptor
by default.
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue28134">bpo-28134</a>.)</p>
</div>
<div class="section" id="socketserver">
<h3>socketserver<a class="headerlink" href="#socketserver" title="Permalink to this headline">¶</a></h3>
<p><code class="xref py py-meth docutils literal notranslate"><span class="pre">socketserver.ThreadingMixIn.server_close()</span></code> now waits until all non-daemon
threads complete. <code class="xref py py-meth docutils literal notranslate"><span class="pre">socketserver.ForkingMixIn.server_close()</span></code> now waits
until all child processes complete.</p>
<p>Add a new <code class="xref py py-attr docutils literal notranslate"><span class="pre">socketserver.ForkingMixIn.block_on_close</span></code> class attribute to
<a class="reference internal" href="../library/socketserver.html#socketserver.ForkingMixIn" title="socketserver.ForkingMixIn"><code class="xref py py-class docutils literal notranslate"><span class="pre">socketserver.ForkingMixIn</span></code></a> and <a class="reference internal" href="../library/socketserver.html#socketserver.ThreadingMixIn" title="socketserver.ThreadingMixIn"><code class="xref py py-class docutils literal notranslate"><span class="pre">socketserver.ThreadingMixIn</span></code></a>
classes. Set the class attribute to <code class="docutils literal notranslate"><span class="pre">False</span></code> to get the pre-3.7 behaviour.</p>
</div>
<div class="section" id="sqlite3">
<h3>sqlite3<a class="headerlink" href="#sqlite3" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/sqlite3.html#sqlite3.Connection" title="sqlite3.Connection"><code class="xref py py-class docutils literal notranslate"><span class="pre">sqlite3.Connection</span></code></a> now exposes the <a class="reference internal" href="../library/sqlite3.html#sqlite3.Connection.backup" title="sqlite3.Connection.backup"><code class="xref py py-meth docutils literal notranslate"><span class="pre">backup()</span></code></a>
method when the underlying SQLite library is at version 3.6.11 or higher.
(Contributed by Lele Gaifax in <a class="reference external" href="https://bugs.python.org/issue27645">bpo-27645</a>.)</p>
<p>The <em>database</em> argument of <a class="reference internal" href="../library/sqlite3.html#sqlite3.connect" title="sqlite3.connect"><code class="xref py py-func docutils literal notranslate"><span class="pre">sqlite3.connect()</span></code></a> now accepts any
<a class="reference internal" href="../glossary.html#term-path-like-object"><span class="xref std std-term">path-like object</span></a>, instead of just a string.
(Contributed by Anders Lorentsen in <a class="reference external" href="https://bugs.python.org/issue31843">bpo-31843</a>.)</p>
</div>
<div class="section" id="ssl">
<h3>ssl<a class="headerlink" href="#ssl" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../library/ssl.html#module-ssl" title="ssl: TLS/SSL wrapper for socket objects"><code class="xref py py-mod docutils literal notranslate"><span class="pre">ssl</span></code></a> module now uses OpenSSL’s builtin API instead of
<a class="reference internal" href="../library/ssl.html#ssl.match_hostname" title="ssl.match_hostname"><code class="xref py py-func docutils literal notranslate"><span class="pre">match_hostname()</span></code></a> to check a host name or an IP address.  Values
are validated during TLS handshake.  Any certificate validation error
including failing the host name check now raises
<a class="reference internal" href="../library/ssl.html#ssl.SSLCertVerificationError" title="ssl.SSLCertVerificationError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SSLCertVerificationError</span></code></a> and aborts the handshake with a proper
TLS Alert message.  The new exception contains additional information.
Host name validation can be customized with
<a class="reference internal" href="../library/ssl.html#ssl.SSLContext.hostname_checks_common_name" title="ssl.SSLContext.hostname_checks_common_name"><code class="xref py py-attr docutils literal notranslate"><span class="pre">SSLContext.hostname_checks_common_name</span></code></a>.
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue31399">bpo-31399</a>.)</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The improved host name check requires a <em>libssl</em> implementation compatible
with OpenSSL 1.0.2 or 1.1.  Consequently, OpenSSL 0.9.8 and 1.0.1 are no
longer supported (see <a class="reference internal" href="#platform-support-removals"><span class="std std-ref">Platform Support Removals</span></a> for more details).
The ssl module is mostly compatible with LibreSSL 2.7.2 and newer.</p>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">ssl</span></code> module no longer sends IP addresses in SNI TLS extension.
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue32185">bpo-32185</a>.)</p>
<p><a class="reference internal" href="../library/ssl.html#ssl.match_hostname" title="ssl.match_hostname"><code class="xref py py-func docutils literal notranslate"><span class="pre">match_hostname()</span></code></a> no longer supports partial wildcards like
<code class="docutils literal notranslate"><span class="pre">www*.example.org</span></code>.
(Contributed by Mandeep Singh in <a class="reference external" href="https://bugs.python.org/issue23033">bpo-23033</a> and Christian Heimes in
<a class="reference external" href="https://bugs.python.org/issue31399">bpo-31399</a>.)</p>
<p>The default cipher suite selection of the <code class="docutils literal notranslate"><span class="pre">ssl</span></code> module now uses a blacklist
approach rather than a hard-coded whitelist.  Python no longer re-enables
ciphers that have been blocked by OpenSSL security updates.  Default cipher
suite selection can be configured at compile time.
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue31429">bpo-31429</a>.)</p>
<p>Validation of server certificates containing internationalized domain names
(IDNs) is now supported.  As part of this change, the
<a class="reference internal" href="../library/ssl.html#ssl.SSLSocket.server_hostname" title="ssl.SSLSocket.server_hostname"><code class="xref py py-attr docutils literal notranslate"><span class="pre">SSLSocket.server_hostname</span></code></a> attribute
now stores the expected hostname in A-label form (<code class="docutils literal notranslate"><span class="pre">&quot;xn--pythn-mua.org&quot;</span></code>),
rather than the U-label form (<code class="docutils literal notranslate"><span class="pre">&quot;pythön.org&quot;</span></code>).  (Contributed by
Nathaniel J. Smith and Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue28414">bpo-28414</a>.)</p>
<p>The <code class="docutils literal notranslate"><span class="pre">ssl</span></code> module has preliminary and experimental support for TLS 1.3 and
OpenSSL 1.1.1.  At the time of Python 3.7.0 release, OpenSSL 1.1.1 is still
under development and TLS 1.3 hasn’t been finalized yet.  The TLS 1.3
handshake and protocol behaves slightly differently than TLS 1.2 and earlier,
see <a class="reference internal" href="../library/ssl.html#ssl-tlsv1-3"><span class="std std-ref">TLS 1.3</span></a>.
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue32947">bpo-32947</a>, <a class="reference external" href="https://bugs.python.org/issue20995">bpo-20995</a>,
<a class="reference external" href="https://bugs.python.org/issue29136">bpo-29136</a>, <a class="reference external" href="https://bugs.python.org/issue30622">bpo-30622</a> and <a class="reference external" href="https://bugs.python.org/issue33618">bpo-33618</a>)</p>
<p><a class="reference internal" href="../library/ssl.html#ssl.SSLSocket" title="ssl.SSLSocket"><code class="xref py py-class docutils literal notranslate"><span class="pre">SSLSocket</span></code></a> and <a class="reference internal" href="../library/ssl.html#ssl.SSLObject" title="ssl.SSLObject"><code class="xref py py-class docutils literal notranslate"><span class="pre">SSLObject</span></code></a> no longer have a public
constructor.  Direct instantiation was never a documented and supported
feature.  Instances must be created with <a class="reference internal" href="../library/ssl.html#ssl.SSLContext" title="ssl.SSLContext"><code class="xref py py-class docutils literal notranslate"><span class="pre">SSLContext</span></code></a> methods
<a class="reference internal" href="../library/ssl.html#ssl.SSLContext.wrap_socket" title="ssl.SSLContext.wrap_socket"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wrap_socket()</span></code></a> and <a class="reference internal" href="../library/ssl.html#ssl.SSLContext.wrap_bio" title="ssl.SSLContext.wrap_bio"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wrap_bio()</span></code></a>.
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue32951">bpo-32951</a>)</p>
<p>OpenSSL 1.1 APIs for setting the minimum and maximum TLS protocol version are
available as <a class="reference internal" href="../library/ssl.html#ssl.SSLContext.minimum_version" title="ssl.SSLContext.minimum_version"><code class="xref py py-attr docutils literal notranslate"><span class="pre">SSLContext.minimum_version</span></code></a>
and <a class="reference internal" href="../library/ssl.html#ssl.SSLContext.maximum_version" title="ssl.SSLContext.maximum_version"><code class="xref py py-attr docutils literal notranslate"><span class="pre">SSLContext.maximum_version</span></code></a>.
Supported protocols are indicated by several new flags, such as
<a class="reference internal" href="../library/ssl.html#ssl.HAS_TLSv1_1" title="ssl.HAS_TLSv1_1"><code class="xref py py-data docutils literal notranslate"><span class="pre">HAS_TLSv1_1</span></code></a>.
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue32609">bpo-32609</a>.)</p>
</div>
<div class="section" id="string">
<h3>string<a class="headerlink" href="#string" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/string.html#string.Template" title="string.Template"><code class="xref py py-class docutils literal notranslate"><span class="pre">string.Template</span></code></a> now lets you to optionally modify the regular
expression pattern for braced placeholders and non-braced placeholders
separately.  (Contributed by Barry Warsaw in <a class="reference external" href="https://bugs.python.org/issue1198569">bpo-1198569</a>.)</p>
</div>
<div class="section" id="subprocess">
<h3>subprocess<a class="headerlink" href="#subprocess" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../library/subprocess.html#subprocess.run" title="subprocess.run"><code class="xref py py-func docutils literal notranslate"><span class="pre">subprocess.run()</span></code></a> function accepts the new <em>capture_output</em>
keyword argument.  When true, stdout and stderr will be captured.
This is equivalent to passing <a class="reference internal" href="../library/subprocess.html#subprocess.PIPE" title="subprocess.PIPE"><code class="xref py py-data docutils literal notranslate"><span class="pre">subprocess.PIPE</span></code></a> as <em>stdout</em> and
<em>stderr</em> arguments.
(Contributed by Bo Bayles in <a class="reference external" href="https://bugs.python.org/issue32102">bpo-32102</a>.)</p>
<p>The <code class="docutils literal notranslate"><span class="pre">subprocess.run</span></code> function and the <a class="reference internal" href="../library/subprocess.html#subprocess.Popen" title="subprocess.Popen"><code class="xref py py-class docutils literal notranslate"><span class="pre">subprocess.Popen</span></code></a> constructor
now accept the <em>text</em> keyword argument as an alias
to <em>universal_newlines</em>.
(Contributed by Andrew Clegg in <a class="reference external" href="https://bugs.python.org/issue31756">bpo-31756</a>.)</p>
<p>On Windows the default for <em>close_fds</em> was changed from <code class="docutils literal notranslate"><span class="pre">False</span></code> to
<code class="docutils literal notranslate"><span class="pre">True</span></code> when redirecting the standard handles.  It’s now possible to set
<em>close_fds</em> to true when redirecting the standard handles.  See
<a class="reference internal" href="../library/subprocess.html#subprocess.Popen" title="subprocess.Popen"><code class="xref py py-class docutils literal notranslate"><span class="pre">subprocess.Popen</span></code></a>.  This means that <em>close_fds</em> now defaults to
<code class="docutils literal notranslate"><span class="pre">True</span></code> on all supported platforms.
(Contributed by Segev Finer in <a class="reference external" href="https://bugs.python.org/issue19764">bpo-19764</a>.)</p>
<p>The subprocess module is now more graceful when handling
<a class="reference internal" href="../library/exceptions.html#KeyboardInterrupt" title="KeyboardInterrupt"><code class="xref py py-exc docutils literal notranslate"><span class="pre">KeyboardInterrupt</span></code></a> during <a class="reference internal" href="../library/subprocess.html#subprocess.call" title="subprocess.call"><code class="xref py py-func docutils literal notranslate"><span class="pre">subprocess.call()</span></code></a>,
<a class="reference internal" href="../library/subprocess.html#subprocess.run" title="subprocess.run"><code class="xref py py-func docutils literal notranslate"><span class="pre">subprocess.run()</span></code></a>, or in a <a class="reference internal" href="../library/subprocess.html#subprocess.Popen" title="subprocess.Popen"><code class="xref py py-class docutils literal notranslate"><span class="pre">Popen</span></code></a>
context manager.  It now waits a short amount of time for the child
to exit, before continuing the handling of the <code class="docutils literal notranslate"><span class="pre">KeyboardInterrupt</span></code>
exception.
(Contributed by Gregory P. Smith in <a class="reference external" href="https://bugs.python.org/issue25942">bpo-25942</a>.)</p>
</div>
<div class="section" id="sys">
<h3>sys<a class="headerlink" href="#sys" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/sys.html#sys.breakpointhook" title="sys.breakpointhook"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.breakpointhook()</span></code></a> hook function is called by the
built-in <a class="reference internal" href="../library/functions.html#breakpoint" title="breakpoint"><code class="xref py py-func docutils literal notranslate"><span class="pre">breakpoint()</span></code></a>.
(Contributed by Barry Warsaw in <a class="reference external" href="https://bugs.python.org/issue31353">bpo-31353</a>.)</p>
<p>On Android, the new <a class="reference internal" href="../library/sys.html#sys.getandroidapilevel" title="sys.getandroidapilevel"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.getandroidapilevel()</span></code></a> returns the build-time
Android API version.
(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue28740">bpo-28740</a>.)</p>
<p>The new <a class="reference internal" href="../library/sys.html#sys.get_coroutine_origin_tracking_depth" title="sys.get_coroutine_origin_tracking_depth"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.get_coroutine_origin_tracking_depth()</span></code></a> function returns
the current coroutine origin tracking depth, as set by
the new <a class="reference internal" href="../library/sys.html#sys.set_coroutine_origin_tracking_depth" title="sys.set_coroutine_origin_tracking_depth"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.set_coroutine_origin_tracking_depth()</span></code></a>.  <a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code></a>
has been converted to use this new API instead of
the deprecated <code class="xref py py-func docutils literal notranslate"><span class="pre">sys.set_coroutine_wrapper()</span></code>.
(Contributed by Nathaniel J. Smith in <a class="reference external" href="https://bugs.python.org/issue32591">bpo-32591</a>.)</p>
</div>
<div class="section" id="time">
<h3>time<a class="headerlink" href="#time" title="Permalink to this headline">¶</a></h3>
<p><span class="target" id="index-32"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0564"><strong>PEP 564</strong></a> adds six new functions with nanosecond resolution to the
<a class="reference internal" href="../library/time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a> module:</p>
<ul class="simple">
<li><p><a class="reference internal" href="../library/time.html#time.clock_gettime_ns" title="time.clock_gettime_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.clock_gettime_ns()</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/time.html#time.clock_settime_ns" title="time.clock_settime_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.clock_settime_ns()</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/time.html#time.monotonic_ns" title="time.monotonic_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.monotonic_ns()</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/time.html#time.perf_counter_ns" title="time.perf_counter_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.perf_counter_ns()</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/time.html#time.process_time_ns" title="time.process_time_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.process_time_ns()</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/time.html#time.time_ns" title="time.time_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.time_ns()</span></code></a></p></li>
</ul>
<p>New clock identifiers have been added:</p>
<ul class="simple">
<li><p><a class="reference internal" href="../library/time.html#time.CLOCK_BOOTTIME" title="time.CLOCK_BOOTTIME"><code class="xref py py-data docutils literal notranslate"><span class="pre">time.CLOCK_BOOTTIME</span></code></a> (Linux): Identical to
<a class="reference internal" href="../library/time.html#time.CLOCK_MONOTONIC" title="time.CLOCK_MONOTONIC"><code class="xref py py-data docutils literal notranslate"><span class="pre">time.CLOCK_MONOTONIC</span></code></a>, except it also includes any time that the
system is suspended.</p></li>
<li><p><a class="reference internal" href="../library/time.html#time.CLOCK_PROF" title="time.CLOCK_PROF"><code class="xref py py-data docutils literal notranslate"><span class="pre">time.CLOCK_PROF</span></code></a> (FreeBSD, NetBSD and OpenBSD): High-resolution
per-process CPU timer.</p></li>
<li><p><a class="reference internal" href="../library/time.html#time.CLOCK_UPTIME" title="time.CLOCK_UPTIME"><code class="xref py py-data docutils literal notranslate"><span class="pre">time.CLOCK_UPTIME</span></code></a> (FreeBSD, OpenBSD): Time whose absolute value is
the time the system has been running and not suspended, providing accurate
uptime measurement.</p></li>
</ul>
<p>The new <a class="reference internal" href="../library/time.html#time.thread_time" title="time.thread_time"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.thread_time()</span></code></a> and <a class="reference internal" href="../library/time.html#time.thread_time_ns" title="time.thread_time_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.thread_time_ns()</span></code></a> functions
can be used to get per-thread CPU time measurements.
(Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue32025">bpo-32025</a>.)</p>
<p>The new <a class="reference internal" href="../library/time.html#time.pthread_getcpuclockid" title="time.pthread_getcpuclockid"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.pthread_getcpuclockid()</span></code></a> function returns the clock ID
of the thread-specific CPU-time clock.</p>
</div>
<div class="section" id="tkinter">
<h3>tkinter<a class="headerlink" href="#tkinter" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/tkinter.ttk.html#tkinter.ttk.Spinbox" title="tkinter.ttk.Spinbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">tkinter.ttk.Spinbox</span></code></a> class is now available.
(Contributed by Alan Moore in <a class="reference external" href="https://bugs.python.org/issue32585">bpo-32585</a>.)</p>
</div>
<div class="section" id="tracemalloc">
<h3>tracemalloc<a class="headerlink" href="#tracemalloc" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/tracemalloc.html#tracemalloc.Traceback" title="tracemalloc.Traceback"><code class="xref py py-class docutils literal notranslate"><span class="pre">tracemalloc.Traceback</span></code></a> behaves more like regular tracebacks,
sorting the frames from oldest to most recent.
<a class="reference internal" href="../library/tracemalloc.html#tracemalloc.Traceback.format" title="tracemalloc.Traceback.format"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Traceback.format()</span></code></a>
now accepts negative <em>limit</em>, truncating the result to the
<code class="docutils literal notranslate"><span class="pre">abs(limit)</span></code> oldest frames.  To get the old behaviour, use
the new <em>most_recent_first</em> argument to <code class="docutils literal notranslate"><span class="pre">Traceback.format()</span></code>.
(Contributed by Jesse Bakker in <a class="reference external" href="https://bugs.python.org/issue32121">bpo-32121</a>.)</p>
</div>
<div class="section" id="types">
<h3>types<a class="headerlink" href="#types" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/types.html#types.WrapperDescriptorType" title="types.WrapperDescriptorType"><code class="xref py py-class docutils literal notranslate"><span class="pre">WrapperDescriptorType</span></code></a>,
<a class="reference internal" href="../library/types.html#types.MethodWrapperType" title="types.MethodWrapperType"><code class="xref py py-class docutils literal notranslate"><span class="pre">MethodWrapperType</span></code></a>, <a class="reference internal" href="../library/types.html#types.MethodDescriptorType" title="types.MethodDescriptorType"><code class="xref py py-class docutils literal notranslate"><span class="pre">MethodDescriptorType</span></code></a>,
and <a class="reference internal" href="../library/types.html#types.ClassMethodDescriptorType" title="types.ClassMethodDescriptorType"><code class="xref py py-class docutils literal notranslate"><span class="pre">ClassMethodDescriptorType</span></code></a> classes are now available.
(Contributed by Manuel Krebber and Guido van Rossum in <a class="reference external" href="https://bugs.python.org/issue29377">bpo-29377</a>,
and Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue32265">bpo-32265</a>.)</p>
<p>The new <a class="reference internal" href="../library/types.html#types.resolve_bases" title="types.resolve_bases"><code class="xref py py-func docutils literal notranslate"><span class="pre">types.resolve_bases()</span></code></a> function resolves MRO entries
dynamically as specified by <span class="target" id="index-33"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0560"><strong>PEP 560</strong></a>.
(Contributed by Ivan Levkivskyi in <a class="reference external" href="https://bugs.python.org/issue32717">bpo-32717</a>.)</p>
</div>
<div class="section" id="unicodedata">
<h3>unicodedata<a class="headerlink" href="#unicodedata" title="Permalink to this headline">¶</a></h3>
<p>The internal <a class="reference internal" href="../library/unicodedata.html#module-unicodedata" title="unicodedata: Access the Unicode Database."><code class="xref py py-mod docutils literal notranslate"><span class="pre">unicodedata</span></code></a> database has been upgraded to use <a class="reference external" href="http://www.unicode.org/versions/Unicode11.0.0/">Unicode 11</a>. (Contributed by Benjamin
Peterson.)</p>
</div>
<div class="section" id="unittest">
<h3>unittest<a class="headerlink" href="#unittest" title="Permalink to this headline">¶</a></h3>
<p>The new <code class="docutils literal notranslate"><span class="pre">-k</span></code> command-line option allows filtering tests by a name
substring or a Unix shell-like pattern.
For example, <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">unittest</span> <span class="pre">-k</span> <span class="pre">foo</span></code> runs
<code class="docutils literal notranslate"><span class="pre">foo_tests.SomeTest.test_something</span></code>, <code class="docutils literal notranslate"><span class="pre">bar_tests.SomeTest.test_foo</span></code>,
but not <code class="docutils literal notranslate"><span class="pre">bar_tests.FooTest.test_something</span></code>.
(Contributed by Jonas Haag in <a class="reference external" href="https://bugs.python.org/issue32071">bpo-32071</a>.)</p>
</div>
<div class="section" id="unittest-mock">
<h3>unittest.mock<a class="headerlink" href="#unittest-mock" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../library/unittest.mock.html#unittest.mock.sentinel" title="unittest.mock.sentinel"><code class="xref py py-const docutils literal notranslate"><span class="pre">sentinel</span></code></a> attributes now preserve their identity
when they are <a class="reference internal" href="../library/copy.html#module-copy" title="copy: Shallow and deep copy operations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">copied</span></code></a> or <a class="reference internal" href="../library/pickle.html#module-pickle" title="pickle: Convert Python objects to streams of bytes and back."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pickled</span></code></a>. (Contributed by
Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue20804">bpo-20804</a>.)</p>
<p>The new <a class="reference internal" href="../library/unittest.mock.html#unittest.mock.seal" title="unittest.mock.seal"><code class="xref py py-func docutils literal notranslate"><span class="pre">seal()</span></code></a> function allows sealing
<a class="reference internal" href="../library/unittest.mock.html#unittest.mock.Mock" title="unittest.mock.Mock"><code class="xref py py-class docutils literal notranslate"><span class="pre">Mock</span></code></a> instances, which will disallow further creation
of attribute mocks.  The seal is applied recursively to all attributes that
are themselves mocks.
(Contributed by Mario Corchero in <a class="reference external" href="https://bugs.python.org/issue30541">bpo-30541</a>.)</p>
</div>
<div class="section" id="urllib-parse">
<h3>urllib.parse<a class="headerlink" href="#urllib-parse" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/urllib.parse.html#urllib.parse.quote" title="urllib.parse.quote"><code class="xref py py-func docutils literal notranslate"><span class="pre">urllib.parse.quote()</span></code></a> has been updated from <span class="target" id="index-34"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc2396.html"><strong>RFC 2396</strong></a> to <span class="target" id="index-35"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc3986.html"><strong>RFC 3986</strong></a>,
adding <code class="docutils literal notranslate"><span class="pre">~</span></code> to the set of characters that are never quoted by default.
(Contributed by Christian Theune and Ratnadeep Debnath in <a class="reference external" href="https://bugs.python.org/issue16285">bpo-16285</a>.)</p>
</div>
<div class="section" id="uu">
<h3>uu<a class="headerlink" href="#uu" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../library/uu.html#uu.encode" title="uu.encode"><code class="xref py py-func docutils literal notranslate"><span class="pre">uu.encode()</span></code></a> function now accepts an optional <em>backtick</em>
keyword argument.  When it’s true, zeros are represented by <code class="docutils literal notranslate"><span class="pre">'`'</span></code>
instead of spaces.  (Contributed by Xiang Zhang in <a class="reference external" href="https://bugs.python.org/issue30103">bpo-30103</a>.)</p>
</div>
<div class="section" id="uuid">
<h3>uuid<a class="headerlink" href="#uuid" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../library/uuid.html#uuid.UUID.is_safe" title="uuid.UUID.is_safe"><code class="xref py py-attr docutils literal notranslate"><span class="pre">UUID.is_safe</span></code></a> attribute relays information
from the platform about whether generated UUIDs are generated with a
multiprocessing-safe method.
(Contributed by Barry Warsaw in <a class="reference external" href="https://bugs.python.org/issue22807">bpo-22807</a>.)</p>
<p><a class="reference internal" href="../library/uuid.html#uuid.getnode" title="uuid.getnode"><code class="xref py py-func docutils literal notranslate"><span class="pre">uuid.getnode()</span></code></a> now prefers universally administered
MAC addresses over locally administered MAC addresses.
This makes a better guarantee for global uniqueness of UUIDs returned
from <a class="reference internal" href="../library/uuid.html#uuid.uuid1" title="uuid.uuid1"><code class="xref py py-func docutils literal notranslate"><span class="pre">uuid.uuid1()</span></code></a>.  If only locally administered MAC addresses are
available, the first such one found is returned.
(Contributed by Barry Warsaw in <a class="reference external" href="https://bugs.python.org/issue32107">bpo-32107</a>.)</p>
</div>
<div class="section" id="warnings">
<h3>warnings<a class="headerlink" href="#warnings" title="Permalink to this headline">¶</a></h3>
<p>The initialization of the default warnings filters has changed as follows:</p>
<ul>
<li><p>warnings enabled via command line options (including those for <a class="reference internal" href="../using/cmdline.html#cmdoption-b"><code class="xref std std-option docutils literal notranslate"><span class="pre">-b</span></code></a>
and the new CPython-specific <a class="reference internal" href="../using/cmdline.html#id5"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a> <code class="docutils literal notranslate"><span class="pre">dev</span></code> option) are always passed
to the warnings machinery via the <a class="reference internal" href="../library/sys.html#sys.warnoptions" title="sys.warnoptions"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.warnoptions</span></code></a> attribute.</p></li>
<li><p>warnings filters enabled via the command line or the environment now have the
following order of precedence:</p>
<blockquote>
<div><ul class="simple">
<li><p>the <code class="docutils literal notranslate"><span class="pre">BytesWarning</span></code> filter for <a class="reference internal" href="../using/cmdline.html#cmdoption-b"><code class="xref std std-option docutils literal notranslate"><span class="pre">-b</span></code></a> (or <code class="docutils literal notranslate"><span class="pre">-bb</span></code>)</p></li>
<li><p>any filters specified with the <a class="reference internal" href="../using/cmdline.html#cmdoption-w"><code class="xref std std-option docutils literal notranslate"><span class="pre">-W</span></code></a> option</p></li>
<li><p>any filters specified with the <span class="target" id="index-36"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONWARNINGS"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONWARNINGS</span></code></a> environment
variable</p></li>
<li><p>any other CPython specific filters (e.g. the <code class="docutils literal notranslate"><span class="pre">default</span></code> filter added
for the new <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">dev</span></code> mode)</p></li>
<li><p>any implicit filters defined directly by the warnings machinery</p></li>
</ul>
</div></blockquote>
</li>
<li><p>in CPython debug builds, all warnings are now displayed by default (the
implicit filter list is empty)</p></li>
</ul>
<p>(Contributed by Nick Coghlan and Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue20361">bpo-20361</a>,
<a class="reference external" href="https://bugs.python.org/issue32043">bpo-32043</a>, and <a class="reference external" href="https://bugs.python.org/issue32230">bpo-32230</a>.)</p>
<p>Deprecation warnings are once again shown by default in single-file scripts and
at the interactive prompt.  See <a class="reference internal" href="#whatsnew37-pep565"><span class="std std-ref">PEP 565: Show DeprecationWarning in __main__</span></a> for details.
(Contributed by Nick Coghlan in <a class="reference external" href="https://bugs.python.org/issue31975">bpo-31975</a>.)</p>
</div>
<div class="section" id="xml-etree">
<h3>xml.etree<a class="headerlink" href="#xml-etree" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/xml.etree.elementtree.html#elementtree-xpath"><span class="std std-ref">ElementPath</span></a> predicates in the <code class="xref py py-meth docutils literal notranslate"><span class="pre">find()</span></code>
methods can now compare text of the current node with <code class="docutils literal notranslate"><span class="pre">[.</span> <span class="pre">=</span> <span class="pre">&quot;text&quot;]</span></code>,
not only text in children.  Predicates also allow adding spaces for
better readability.  (Contributed by Stefan Behnel in <a class="reference external" href="https://bugs.python.org/issue31648">bpo-31648</a>.)</p>
</div>
<div class="section" id="xmlrpc-server">
<h3>xmlrpc.server<a class="headerlink" href="#xmlrpc-server" title="Permalink to this headline">¶</a></h3>
<p><code class="xref py py-meth docutils literal notranslate"><span class="pre">SimpleXMLRPCDispatcher.register_function</span></code>
can now be used as a decorator.  (Contributed by Xiang Zhang in
<a class="reference external" href="https://bugs.python.org/issue7769">bpo-7769</a>.)</p>
</div>
<div class="section" id="zipapp">
<h3>zipapp<a class="headerlink" href="#zipapp" title="Permalink to this headline">¶</a></h3>
<p>Function <a class="reference internal" href="../library/zipapp.html#zipapp.create_archive" title="zipapp.create_archive"><code class="xref py py-func docutils literal notranslate"><span class="pre">create_archive()</span></code></a> now accepts an optional <em>filter</em>
argument to allow the user to select which files should be included in the
archive.  (Contributed by Irmen de Jong in <a class="reference external" href="https://bugs.python.org/issue31072">bpo-31072</a>.)</p>
<p>Function <a class="reference internal" href="../library/zipapp.html#zipapp.create_archive" title="zipapp.create_archive"><code class="xref py py-func docutils literal notranslate"><span class="pre">create_archive()</span></code></a> now accepts an optional <em>compressed</em>
argument to generate a compressed archive.  A command line option
<code class="docutils literal notranslate"><span class="pre">--compress</span></code> has also been added to support compression.
(Contributed by Zhiming Wang in <a class="reference external" href="https://bugs.python.org/issue31638">bpo-31638</a>.)</p>
</div>
<div class="section" id="zipfile">
<h3>zipfile<a class="headerlink" href="#zipfile" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/zipfile.html#zipfile.ZipFile" title="zipfile.ZipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">ZipFile</span></code></a> now accepts the new <em>compresslevel</em> parameter to
control the compression level.
(Contributed by Bo Bayles in <a class="reference external" href="https://bugs.python.org/issue21417">bpo-21417</a>.)</p>
<p>Subdirectories in archives created by <code class="docutils literal notranslate"><span class="pre">ZipFile</span></code> are now stored in
alphabetical order.
(Contributed by Bernhard M. Wiedemann in <a class="reference external" href="https://bugs.python.org/issue30693">bpo-30693</a>.)</p>
</div>
</div>
<div class="section" id="c-api-changes">
<h2>C API Changes<a class="headerlink" href="#c-api-changes" title="Permalink to this headline">¶</a></h2>
<p>A new API for thread-local storage has been implemented.  See
<a class="reference internal" href="#whatsnew37-pep539"><span class="std std-ref">PEP 539: New C API for Thread-Local Storage</span></a> for an overview and
<a class="reference internal" href="../c-api/init.html#thread-specific-storage-api"><span class="std std-ref">Thread Specific Storage (TSS) API</span></a> for a complete reference.
(Contributed by Masayuki Yamamoto in <a class="reference external" href="https://bugs.python.org/issue25658">bpo-25658</a>.)</p>
<p>The new <a class="reference internal" href="#whatsnew37-pep567"><span class="std std-ref">context variables</span></a> functionality
exposes a number of <a class="reference internal" href="../c-api/contextvars.html#contextvarsobjects"><span class="std std-ref">new C APIs</span></a>.</p>
<p>The new <a class="reference internal" href="../c-api/import.html#c.PyImport_GetModule" title="PyImport_GetModule"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyImport_GetModule()</span></code></a> function returns the previously
imported module with the given name.
(Contributed by Eric Snow in <a class="reference external" href="https://bugs.python.org/issue28411">bpo-28411</a>.)</p>
<p>The new <a class="reference internal" href="../c-api/typeobj.html#c.Py_RETURN_RICHCOMPARE" title="Py_RETURN_RICHCOMPARE"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_RETURN_RICHCOMPARE</span></code></a> macro eases writing rich
comparison functions.
(Contributed by Petr Victorin in <a class="reference external" href="https://bugs.python.org/issue23699">bpo-23699</a>.)</p>
<p>The new <a class="reference internal" href="../c-api/intro.html#c.Py_UNREACHABLE" title="Py_UNREACHABLE"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_UNREACHABLE</span></code></a> macro can be used to mark unreachable
code paths.
(Contributed by Barry Warsaw in <a class="reference external" href="https://bugs.python.org/issue31338">bpo-31338</a>.)</p>
<p>The <a class="reference internal" href="../library/tracemalloc.html#module-tracemalloc" title="tracemalloc: Trace memory allocations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tracemalloc</span></code></a> now exposes a C API through the new
<a class="reference internal" href="../c-api/memory.html#c.PyTraceMalloc_Track" title="PyTraceMalloc_Track"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyTraceMalloc_Track()</span></code></a> and <a class="reference internal" href="../c-api/memory.html#c.PyTraceMalloc_Untrack" title="PyTraceMalloc_Untrack"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyTraceMalloc_Untrack()</span></code></a>
functions.
(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue30054">bpo-30054</a>.)</p>
<p>The new <code class="xref c c-func docutils literal notranslate"><span class="pre">import__find__load__start()</span></code> and
<code class="xref c c-func docutils literal notranslate"><span class="pre">import__find__load__done()</span></code> static markers can be used to trace
module imports.
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue31574">bpo-31574</a>.)</p>
<p>The fields <code class="xref c c-member docutils literal notranslate"><span class="pre">name</span></code> and <code class="xref c c-member docutils literal notranslate"><span class="pre">doc</span></code> of structures
<a class="reference internal" href="../c-api/structures.html#c.PyMemberDef" title="PyMemberDef"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyMemberDef</span></code></a>, <a class="reference internal" href="../c-api/structures.html#c.PyGetSetDef" title="PyGetSetDef"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyGetSetDef</span></code></a>,
<a class="reference internal" href="../c-api/tuple.html#c.PyStructSequence_Field" title="PyStructSequence_Field"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyStructSequence_Field</span></code></a>, <a class="reference internal" href="../c-api/tuple.html#c.PyStructSequence_Desc" title="PyStructSequence_Desc"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyStructSequence_Desc</span></code></a>,
and <code class="xref c c-type docutils literal notranslate"><span class="pre">wrapperbase</span></code> are now of type <code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*</span></code> rather of
<code class="docutils literal notranslate"><span class="pre">char</span> <span class="pre">*</span></code>.  (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue28761">bpo-28761</a>.)</p>
<p>The result of <a class="reference internal" href="../c-api/unicode.html#c.PyUnicode_AsUTF8AndSize" title="PyUnicode_AsUTF8AndSize"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_AsUTF8AndSize()</span></code></a> and <a class="reference internal" href="../c-api/unicode.html#c.PyUnicode_AsUTF8" title="PyUnicode_AsUTF8"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_AsUTF8()</span></code></a>
is now of type <code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*</span></code> rather of <code class="docutils literal notranslate"><span class="pre">char</span> <span class="pre">*</span></code>. (Contributed by Serhiy
Storchaka in <a class="reference external" href="https://bugs.python.org/issue28769">bpo-28769</a>.)</p>
<p>The result of <a class="reference internal" href="../c-api/mapping.html#c.PyMapping_Keys" title="PyMapping_Keys"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyMapping_Keys()</span></code></a>, <a class="reference internal" href="../c-api/mapping.html#c.PyMapping_Values" title="PyMapping_Values"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyMapping_Values()</span></code></a> and
<a class="reference internal" href="../c-api/mapping.html#c.PyMapping_Items" title="PyMapping_Items"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyMapping_Items()</span></code></a> is now always a list, rather than a list or a
tuple. (Contributed by Oren Milman in <a class="reference external" href="https://bugs.python.org/issue28280">bpo-28280</a>.)</p>
<p>Added functions <a class="reference internal" href="../c-api/slice.html#c.PySlice_Unpack" title="PySlice_Unpack"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySlice_Unpack()</span></code></a> and <a class="reference internal" href="../c-api/slice.html#c.PySlice_AdjustIndices" title="PySlice_AdjustIndices"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySlice_AdjustIndices()</span></code></a>.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue27867">bpo-27867</a>.)</p>
<p><a class="reference internal" href="../c-api/sys.html#c.PyOS_AfterFork" title="PyOS_AfterFork"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_AfterFork()</span></code></a> is deprecated in favour of the new functions
<a class="reference internal" href="../c-api/sys.html#c.PyOS_BeforeFork" title="PyOS_BeforeFork"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_BeforeFork()</span></code></a>, <a class="reference internal" href="../c-api/sys.html#c.PyOS_AfterFork_Parent" title="PyOS_AfterFork_Parent"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_AfterFork_Parent()</span></code></a> and
<a class="reference internal" href="../c-api/sys.html#c.PyOS_AfterFork_Child" title="PyOS_AfterFork_Child"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_AfterFork_Child()</span></code></a>.  (Contributed by Antoine Pitrou in
<a class="reference external" href="https://bugs.python.org/issue16500">bpo-16500</a>.)</p>
<p>The <code class="docutils literal notranslate"><span class="pre">PyExc_RecursionErrorInst</span></code> singleton that was part of the public API
has been removed as its members being never cleared may cause a segfault
during finalization of the interpreter. Contributed by Xavier de Gaye in
<a class="reference external" href="https://bugs.python.org/issue22898">bpo-22898</a> and <a class="reference external" href="https://bugs.python.org/issue30697">bpo-30697</a>.</p>
<p>Added C API support for timezones with timezone constructors
<a class="reference internal" href="../c-api/datetime.html#c.PyTimeZone_FromOffset" title="PyTimeZone_FromOffset"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyTimeZone_FromOffset()</span></code></a> and <a class="reference internal" href="../c-api/datetime.html#c.PyTimeZone_FromOffsetAndName" title="PyTimeZone_FromOffsetAndName"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyTimeZone_FromOffsetAndName()</span></code></a>,
and access to the UTC singleton with <a class="reference internal" href="../c-api/datetime.html#c.PyDateTime_TimeZone_UTC" title="PyDateTime_TimeZone_UTC"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyDateTime_TimeZone_UTC</span></code></a>.
Contributed by Paul Ganssle in <a class="reference external" href="https://bugs.python.org/issue10381">bpo-10381</a>.</p>
<p>The type of results of <code class="xref c c-func docutils literal notranslate"><span class="pre">PyThread_start_new_thread()</span></code> and
<code class="xref c c-func docutils literal notranslate"><span class="pre">PyThread_get_thread_ident()</span></code>, and the <em>id</em> parameter of
<a class="reference internal" href="../c-api/init.html#c.PyThreadState_SetAsyncExc" title="PyThreadState_SetAsyncExc"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyThreadState_SetAsyncExc()</span></code></a> changed from <code class="xref c c-type docutils literal notranslate"><span class="pre">long</span></code> to
<code class="xref c c-type docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">long</span></code>.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue6532">bpo-6532</a>.)</p>
<p><a class="reference internal" href="../c-api/unicode.html#c.PyUnicode_AsWideCharString" title="PyUnicode_AsWideCharString"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_AsWideCharString()</span></code></a> now raises a <a class="reference internal" href="../library/exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> if the
second argument is <code class="docutils literal notranslate"><span class="pre">NULL</span></code> and the <code class="xref c c-type docutils literal notranslate"><span class="pre">wchar_t*</span></code> string contains null
characters.  (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue30708">bpo-30708</a>.)</p>
<p>Changes to the startup sequence and the management of dynamic memory
allocators mean that the long documented requirement to call
<a class="reference internal" href="../c-api/init.html#c.Py_Initialize" title="Py_Initialize"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_Initialize()</span></code></a> before calling most C API functions is now
relied on more heavily, and failing to abide by it may lead to segfaults in
embedding applications. See the <a class="reference internal" href="#porting-to-python-37"><span class="std std-ref">Porting to Python 3.7</span></a> section in this
document and the <a class="reference internal" href="../c-api/init.html#pre-init-safe"><span class="std std-ref">Before Python Initialization</span></a> section in the C API documentation
for more details.</p>
<p>The new <a class="reference internal" href="../c-api/init.html#c.PyInterpreterState_GetID" title="PyInterpreterState_GetID"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyInterpreterState_GetID()</span></code></a> returns the unique ID for a
given interpreter.
(Contributed by Eric Snow in <a class="reference external" href="https://bugs.python.org/issue29102">bpo-29102</a>.)</p>
<p><a class="reference internal" href="../c-api/sys.html#c.Py_DecodeLocale" title="Py_DecodeLocale"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_DecodeLocale()</span></code></a>, <a class="reference internal" href="../c-api/sys.html#c.Py_EncodeLocale" title="Py_EncodeLocale"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_EncodeLocale()</span></code></a> now use the UTF-8
encoding when the <a class="reference internal" href="#whatsnew37-pep540"><span class="std std-ref">UTF-8 mode</span></a> is enabled.
(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue29240">bpo-29240</a>.)</p>
<p><a class="reference internal" href="../c-api/unicode.html#c.PyUnicode_DecodeLocaleAndSize" title="PyUnicode_DecodeLocaleAndSize"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_DecodeLocaleAndSize()</span></code></a> and <a class="reference internal" href="../c-api/unicode.html#c.PyUnicode_EncodeLocale" title="PyUnicode_EncodeLocale"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_EncodeLocale()</span></code></a>
now use the current locale encoding for <code class="docutils literal notranslate"><span class="pre">surrogateescape</span></code> error handler.
(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue29240">bpo-29240</a>.)</p>
<p>The <em>start</em> and <em>end</em> parameters of <a class="reference internal" href="../c-api/unicode.html#c.PyUnicode_FindChar" title="PyUnicode_FindChar"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_FindChar()</span></code></a> are
now adjusted to behave like string slices.
(Contributed by Xiang Zhang in <a class="reference external" href="https://bugs.python.org/issue28822">bpo-28822</a>.)</p>
</div>
<div class="section" id="build-changes">
<h2>Build Changes<a class="headerlink" href="#build-changes" title="Permalink to this headline">¶</a></h2>
<p>Support for building <code class="docutils literal notranslate"><span class="pre">--without-threads</span></code> has been removed.  The
<a class="reference internal" href="../library/threading.html#module-threading" title="threading: Thread-based parallelism."><code class="xref py py-mod docutils literal notranslate"><span class="pre">threading</span></code></a> module is now always available.
(Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue31370">bpo-31370</a>.).</p>
<p>A full copy of libffi is no longer bundled for use when building the
<a class="reference internal" href="../library/ctypes.html#module-ctypes" title="ctypes: A foreign function library for Python."><code class="xref py py-mod docutils literal notranslate"><span class="pre">_ctypes</span></code></a> module on non-OSX UNIX platforms.  An installed copy
of libffi is now required when building <code class="docutils literal notranslate"><span class="pre">_ctypes</span></code> on such platforms.
(Contributed by Zachary Ware in <a class="reference external" href="https://bugs.python.org/issue27979">bpo-27979</a>.)</p>
<p>The Windows build process no longer depends on Subversion to pull in external
sources, a Python script is used to download zipfiles from GitHub instead.
If Python 3.6 is not found on the system (via <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-3.6</span></code>), NuGet is used to
download a copy of 32-bit Python for this purpose.  (Contributed by Zachary
Ware in <a class="reference external" href="https://bugs.python.org/issue30450">bpo-30450</a>.)</p>
<p>The <a class="reference internal" href="../library/ssl.html#module-ssl" title="ssl: TLS/SSL wrapper for socket objects"><code class="xref py py-mod docutils literal notranslate"><span class="pre">ssl</span></code></a> module requires OpenSSL 1.0.2 or 1.1 compatible libssl.
OpenSSL 1.0.1 has reached end of lifetime on 2016-12-31 and is no longer
supported. LibreSSL is temporarily not supported as well. LibreSSL releases
up to version 2.6.4 are missing required OpenSSL 1.0.2 APIs.</p>
</div>
<div class="section" id="optimizations">
<span id="whatsnew37-perf"></span><h2>Optimizations<a class="headerlink" href="#optimizations" title="Permalink to this headline">¶</a></h2>
<p>The overhead of calling many methods of various standard library classes
implemented in C has been significantly reduced by porting more code
to use the <code class="docutils literal notranslate"><span class="pre">METH_FASTCALL</span></code> convention.
(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue29300">bpo-29300</a>, <a class="reference external" href="https://bugs.python.org/issue29507">bpo-29507</a>,
<a class="reference external" href="https://bugs.python.org/issue29452">bpo-29452</a>, and <a class="reference external" href="https://bugs.python.org/issue29286">bpo-29286</a>.)</p>
<p>Various optimizations have reduced Python startup time by 10% on Linux and
up to 30% on macOS.
(Contributed by Victor Stinner, INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue29585">bpo-29585</a>, and
Ivan Levkivskyi in <a class="reference external" href="https://bugs.python.org/issue31333">bpo-31333</a>.)</p>
<p>Method calls are now up to 20% faster due to the bytecode changes which
avoid creating bound method instances.
(Contributed by Yury Selivanov and INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue26110">bpo-26110</a>.)</p>
<p id="whatsnew37-asyncio-perf">The <a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code></a> module received a number of notable optimizations for
commonly used functions:</p>
<ul class="simple">
<li><p>The <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.get_event_loop" title="asyncio.get_event_loop"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.get_event_loop()</span></code></a> function has been reimplemented in C to
make it up to 15 times faster.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue32296">bpo-32296</a>.)</p></li>
<li><p><a class="reference internal" href="../library/asyncio-future.html#asyncio.Future" title="asyncio.Future"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.Future</span></code></a> callback management has been optimized.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue32348">bpo-32348</a>.)</p></li>
<li><p><a class="reference internal" href="../library/asyncio-task.html#asyncio.gather" title="asyncio.gather"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.gather()</span></code></a> is now up to 15% faster.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue32355">bpo-32355</a>.)</p></li>
<li><p><a class="reference internal" href="../library/asyncio-task.html#asyncio.sleep" title="asyncio.sleep"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.sleep()</span></code></a> is now up to 2 times faster when the <em>delay</em>
argument is zero or negative.
(Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue32351">bpo-32351</a>.)</p></li>
<li><p>The performance overhead of asyncio debug mode has been reduced.
(Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue31970">bpo-31970</a>.)</p></li>
</ul>
<p>As a result of <a class="reference internal" href="#whatsnew37-pep560"><span class="std std-ref">PEP 560 work</span></a>, the import time
of <a class="reference internal" href="../library/typing.html#module-typing" title="typing: Support for type hints (see :pep:`484`)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">typing</span></code></a> has been reduced by a factor of 7, and many typing operations
are now faster.
(Contributed by Ivan Levkivskyi in <a class="reference external" href="https://bugs.python.org/issue32226">bpo-32226</a>.)</p>
<p><a class="reference internal" href="../library/functions.html#sorted" title="sorted"><code class="xref py py-func docutils literal notranslate"><span class="pre">sorted()</span></code></a> and <a class="reference internal" href="../library/stdtypes.html#list.sort" title="list.sort"><code class="xref py py-meth docutils literal notranslate"><span class="pre">list.sort()</span></code></a> have been optimized for common cases
to be up to 40-75% faster.
(Contributed by Elliot Gorokhovsky in <a class="reference external" href="https://bugs.python.org/issue28685">bpo-28685</a>.)</p>
<p><a class="reference internal" href="../library/stdtypes.html#dict.copy" title="dict.copy"><code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.copy()</span></code></a> is now up to 5.5 times faster.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue31179">bpo-31179</a>.)</p>
<p><a class="reference internal" href="../library/functions.html#hasattr" title="hasattr"><code class="xref py py-func docutils literal notranslate"><span class="pre">hasattr()</span></code></a> and <a class="reference internal" href="../library/functions.html#getattr" title="getattr"><code class="xref py py-func docutils literal notranslate"><span class="pre">getattr()</span></code></a> are now about 4 times faster when
<em>name</em> is not found and <em>obj</em> does not override <a class="reference internal" href="../reference/datamodel.html#object.__getattr__" title="object.__getattr__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">object.__getattr__()</span></code></a>
or <a class="reference internal" href="../reference/datamodel.html#object.__getattribute__" title="object.__getattribute__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">object.__getattribute__()</span></code></a>.
(Contributed by INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue32544">bpo-32544</a>.)</p>
<p>Searching for certain Unicode characters (like Ukrainian capital “Є”)
in a string was up to 25 times slower than searching for other characters.
It is now only 3 times slower in the worst case.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue24821">bpo-24821</a>.)</p>
<p>The <a class="reference internal" href="../library/collections.html#collections.namedtuple" title="collections.namedtuple"><code class="xref py py-func docutils literal notranslate"><span class="pre">collections.namedtuple()</span></code></a> factory has been reimplemented to
make the creation of named tuples 4 to 6 times faster.
(Contributed by Jelle Zijlstra with further improvements by INADA Naoki,
Serhiy Storchaka, and Raymond Hettinger in <a class="reference external" href="https://bugs.python.org/issue28638">bpo-28638</a>.)</p>
<p><code class="xref py py-meth docutils literal notranslate"><span class="pre">date.fromordinal()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">date.fromtimestamp()</span></code> are now up to
30% faster in the common case.
(Contributed by Paul Ganssle in <a class="reference external" href="https://bugs.python.org/issue32403">bpo-32403</a>.)</p>
<p>The <a class="reference internal" href="../library/os.html#os.fwalk" title="os.fwalk"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.fwalk()</span></code></a> function is now up to 2 times faster thanks to
the use of <a class="reference internal" href="../library/os.html#os.scandir" title="os.scandir"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.scandir()</span></code></a>.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue25996">bpo-25996</a>.)</p>
<p>The speed of the <a class="reference internal" href="../library/shutil.html#shutil.rmtree" title="shutil.rmtree"><code class="xref py py-func docutils literal notranslate"><span class="pre">shutil.rmtree()</span></code></a> function has been improved by
20–40% thanks to the use of the <a class="reference internal" href="../library/os.html#os.scandir" title="os.scandir"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.scandir()</span></code></a> function.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue28564">bpo-28564</a>.)</p>
<p>Optimized case-insensitive matching and searching of <a class="reference internal" href="../library/re.html#module-re" title="re: Regular expression operations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">regular</span>
<span class="pre">expressions</span></code></a>.  Searching some patterns can now be up to 20 times faster.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue30285">bpo-30285</a>.)</p>
<p><a class="reference internal" href="../library/re.html#re.compile" title="re.compile"><code class="xref py py-func docutils literal notranslate"><span class="pre">re.compile()</span></code></a> now converts <code class="docutils literal notranslate"><span class="pre">flags</span></code> parameter to int object if
it is <code class="docutils literal notranslate"><span class="pre">RegexFlag</span></code>.  It is now as fast as Python 3.5, and faster than
Python 3.6 by about 10% depending on the pattern.
(Contributed by INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue31671">bpo-31671</a>.)</p>
<p>The <a class="reference internal" href="../library/selectors.html#selectors.BaseSelector.modify" title="selectors.BaseSelector.modify"><code class="xref py py-meth docutils literal notranslate"><span class="pre">modify()</span></code></a> methods of classes
<a class="reference internal" href="../library/selectors.html#selectors.EpollSelector" title="selectors.EpollSelector"><code class="xref py py-class docutils literal notranslate"><span class="pre">selectors.EpollSelector</span></code></a>, <a class="reference internal" href="../library/selectors.html#selectors.PollSelector" title="selectors.PollSelector"><code class="xref py py-class docutils literal notranslate"><span class="pre">selectors.PollSelector</span></code></a>
and <a class="reference internal" href="../library/selectors.html#selectors.DevpollSelector" title="selectors.DevpollSelector"><code class="xref py py-class docutils literal notranslate"><span class="pre">selectors.DevpollSelector</span></code></a> may be around 10% faster under
heavy loads.  (Contributed by Giampaolo Rodola’ in <a class="reference external" href="https://bugs.python.org/issue30014">bpo-30014</a>)</p>
<p>Constant folding has been moved from the peephole optimizer to the new AST
optimizer, which is able perform optimizations more consistently.
(Contributed by Eugene Toder and INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue29469">bpo-29469</a> and
<a class="reference external" href="https://bugs.python.org/issue11549">bpo-11549</a>.)</p>
<p>Most functions and methods in <a class="reference internal" href="../library/abc.html#module-abc" title="abc: Abstract base classes according to :pep:`3119`."><code class="xref py py-mod docutils literal notranslate"><span class="pre">abc</span></code></a> have been rewritten in C.
This makes creation of abstract base classes, and calling <a class="reference internal" href="../library/functions.html#isinstance" title="isinstance"><code class="xref py py-func docutils literal notranslate"><span class="pre">isinstance()</span></code></a>
and <a class="reference internal" href="../library/functions.html#issubclass" title="issubclass"><code class="xref py py-func docutils literal notranslate"><span class="pre">issubclass()</span></code></a> on them 1.5x faster.  This also reduces Python
start-up time by up to 10%. (Contributed by Ivan Levkivskyi and INADA Naoki
in <a class="reference external" href="https://bugs.python.org/issue31333">bpo-31333</a>)</p>
<p>Significant speed improvements to alternate constructors for
<a class="reference internal" href="../library/datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> and <a class="reference internal" href="../library/datetime.html#datetime.datetime" title="datetime.datetime"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.datetime</span></code></a> by using fast-path
constructors when not constructing subclasses. (Contributed by Paul Ganssle
in <a class="reference external" href="https://bugs.python.org/issue32403">bpo-32403</a>)</p>
<p>The speed of comparison of <a class="reference internal" href="../library/array.html#array.array" title="array.array"><code class="xref py py-class docutils literal notranslate"><span class="pre">array.array</span></code></a> instances has been
improved considerably in certain cases.  It is now from 10x to 70x faster
when comparing arrays holding values of the same integer type.
(Contributed by Adrian Wielgosik in <a class="reference external" href="https://bugs.python.org/issue24700">bpo-24700</a>.)</p>
<p>The <a class="reference internal" href="../library/math.html#math.erf" title="math.erf"><code class="xref py py-func docutils literal notranslate"><span class="pre">math.erf()</span></code></a> and <a class="reference internal" href="../library/math.html#math.erfc" title="math.erfc"><code class="xref py py-func docutils literal notranslate"><span class="pre">math.erfc()</span></code></a> functions now use the (faster)
C library implementation on most platforms.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue26121">bpo-26121</a>.)</p>
</div>
<div class="section" id="other-cpython-implementation-changes">
<h2>Other CPython Implementation Changes<a class="headerlink" href="#other-cpython-implementation-changes" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><p>Trace hooks may now opt out of receiving the <code class="docutils literal notranslate"><span class="pre">line</span></code> and opt into receiving
the <code class="docutils literal notranslate"><span class="pre">opcode</span></code> events from the interpreter by setting the corresponding new
<code class="docutils literal notranslate"><span class="pre">f_trace_lines</span></code> and <code class="docutils literal notranslate"><span class="pre">f_trace_opcodes</span></code> attributes on the
frame being traced. (Contributed by Nick Coghlan in <a class="reference external" href="https://bugs.python.org/issue31344">bpo-31344</a>.)</p></li>
<li><p>Fixed some consistency problems with namespace package module attributes.
Namespace module objects now have an <code class="docutils literal notranslate"><span class="pre">__file__</span></code> that is set to <code class="docutils literal notranslate"><span class="pre">None</span></code>
(previously unset), and their <code class="docutils literal notranslate"><span class="pre">__spec__.origin</span></code> is also set to <code class="docutils literal notranslate"><span class="pre">None</span></code>
(previously the string <code class="docutils literal notranslate"><span class="pre">&quot;namespace&quot;</span></code>).  See <a class="reference external" href="https://bugs.python.org/issue32305">bpo-32305</a>.  Also, the
namespace module object’s <code class="docutils literal notranslate"><span class="pre">__spec__.loader</span></code> is set to the same value as
<code class="docutils literal notranslate"><span class="pre">__loader__</span></code> (previously, the former was set to <code class="docutils literal notranslate"><span class="pre">None</span></code>).  See
<a class="reference external" href="https://bugs.python.org/issue32303">bpo-32303</a>.</p></li>
<li><p>The <a class="reference internal" href="../library/functions.html#locals" title="locals"><code class="xref py py-func docutils literal notranslate"><span class="pre">locals()</span></code></a> dictionary now displays in the lexical order that
variables were defined.  Previously, the order was undefined.
(Contributed by Raymond Hettinger in <a class="reference external" href="https://bugs.python.org/issue32690">bpo-32690</a>.)</p></li>
<li><p>The <a class="reference internal" href="../library/distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a> <code class="docutils literal notranslate"><span class="pre">upload</span></code> command no longer tries to change CR
end-of-line characters to CRLF.  This fixes a corruption issue with sdists
that ended with a byte equivalent to CR.
(Contributed by Bo Bayles in <a class="reference external" href="https://bugs.python.org/issue32304">bpo-32304</a>.)</p></li>
</ul>
</div>
<div class="section" id="deprecated-python-behavior">
<h2>Deprecated Python Behavior<a class="headerlink" href="#deprecated-python-behavior" title="Permalink to this headline">¶</a></h2>
<p>Yield expressions (both <code class="docutils literal notranslate"><span class="pre">yield</span></code> and <code class="docutils literal notranslate"><span class="pre">yield</span> <span class="pre">from</span></code> clauses) are now deprecated
in comprehensions and generator expressions (aside from the iterable expression
in the leftmost <code class="xref std std-keyword docutils literal notranslate"><span class="pre">for</span></code> clause). This ensures that comprehensions
always immediately return a container of the appropriate type (rather than
potentially returning a <a class="reference internal" href="../glossary.html#term-generator-iterator"><span class="xref std std-term">generator iterator</span></a> object), while generator
expressions won’t attempt to interleave their implicit output with the output
from any explicit yield expressions.  In Python 3.7, such expressions emit
<a class="reference internal" href="../library/exceptions.html#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a> when compiled, in Python 3.8 this will be a
<a class="reference internal" href="../library/exceptions.html#SyntaxError" title="SyntaxError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SyntaxError</span></code></a>.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue10544">bpo-10544</a>.)</p>
<p>Returning a subclass of <a class="reference internal" href="../library/functions.html#complex" title="complex"><code class="xref py py-class docutils literal notranslate"><span class="pre">complex</span></code></a> from <a class="reference internal" href="../reference/datamodel.html#object.__complex__" title="object.__complex__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">object.__complex__()</span></code></a> is
deprecated and will be an error in future Python versions.  This makes
<code class="docutils literal notranslate"><span class="pre">__complex__()</span></code> consistent with <a class="reference internal" href="../reference/datamodel.html#object.__int__" title="object.__int__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">object.__int__()</span></code></a> and
<a class="reference internal" href="../reference/datamodel.html#object.__float__" title="object.__float__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">object.__float__()</span></code></a>.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue28894">bpo-28894</a>.)</p>
</div>
<div class="section" id="deprecated-python-modules-functions-and-methods">
<h2>Deprecated Python modules, functions and methods<a class="headerlink" href="#deprecated-python-modules-functions-and-methods" title="Permalink to this headline">¶</a></h2>
<div class="section" id="aifc">
<h3>aifc<a class="headerlink" href="#aifc" title="Permalink to this headline">¶</a></h3>
<p><code class="xref py py-func docutils literal notranslate"><span class="pre">aifc.openfp()</span></code> has been deprecated and will be removed in Python 3.9.
Use <a class="reference internal" href="../library/aifc.html#aifc.open" title="aifc.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">aifc.open()</span></code></a> instead.
(Contributed by Brian Curtin in <a class="reference external" href="https://bugs.python.org/issue31985">bpo-31985</a>.)</p>
</div>
<div class="section" id="whatsnew37-asyncio-deprecated">
<span id="id2"></span><h3>asyncio<a class="headerlink" href="#whatsnew37-asyncio-deprecated" title="Permalink to this headline">¶</a></h3>
<p>Support for directly <code class="docutils literal notranslate"><span class="pre">await</span></code>-ing instances of <a class="reference internal" href="../library/asyncio-sync.html#asyncio.Lock" title="asyncio.Lock"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.Lock</span></code></a> and
other asyncio synchronization primitives has been deprecated.  An
asynchronous context manager must be used in order to acquire and release
the synchronization resource.
(Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue32253">bpo-32253</a>.)</p>
<p>The <a class="reference internal" href="../library/asyncio-task.html#asyncio.Task.current_task" title="asyncio.Task.current_task"><code class="xref py py-meth docutils literal notranslate"><span class="pre">asyncio.Task.current_task()</span></code></a> and <a class="reference internal" href="../library/asyncio-task.html#asyncio.Task.all_tasks" title="asyncio.Task.all_tasks"><code class="xref py py-meth docutils literal notranslate"><span class="pre">asyncio.Task.all_tasks()</span></code></a>
methods have been deprecated.
(Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue32250">bpo-32250</a>.)</p>
</div>
<div class="section" id="id3">
<h3>collections<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h3>
<p>In Python 3.8, the abstract base classes in <a class="reference internal" href="../library/collections.abc.html#module-collections.abc" title="collections.abc: Abstract base classes for containers"><code class="xref py py-mod docutils literal notranslate"><span class="pre">collections.abc</span></code></a> will no
longer be exposed in the regular <a class="reference internal" href="../library/collections.html#module-collections" title="collections: Container datatypes"><code class="xref py py-mod docutils literal notranslate"><span class="pre">collections</span></code></a> module.  This will help
create a clearer distinction between the concrete classes and the abstract
base classes.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue25988">bpo-25988</a>.)</p>
</div>
<div class="section" id="id4">
<h3>dbm<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/dbm.html#module-dbm.dumb" title="dbm.dumb: Portable implementation of the simple DBM interface."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dbm.dumb</span></code></a> now supports reading read-only files and no longer writes the
index file when it is not changed.  A deprecation warning is now emitted
if the index file is missing and recreated in the <code class="docutils literal notranslate"><span class="pre">'r'</span></code> and <code class="docutils literal notranslate"><span class="pre">'w'</span></code>
modes (this will be an error in future Python releases).
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue28847">bpo-28847</a>.)</p>
</div>
<div class="section" id="id5">
<h3>enum<a class="headerlink" href="#id5" title="Permalink to this headline">¶</a></h3>
<p>In Python 3.8, attempting to check for non-Enum objects in <code class="xref py py-class docutils literal notranslate"><span class="pre">Enum</span></code>
classes will raise a <a class="reference internal" href="../library/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> (e.g. <code class="docutils literal notranslate"><span class="pre">1</span> <span class="pre">in</span> <span class="pre">Color</span></code>); similarly,
attempting to check for non-Flag objects in a <code class="xref py py-class docutils literal notranslate"><span class="pre">Flag</span></code> member will
raise <a class="reference internal" href="../library/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> (e.g. <code class="docutils literal notranslate"><span class="pre">1</span> <span class="pre">in</span> <span class="pre">Perm.RW</span></code>); currently, both operations
return <a class="reference internal" href="../library/constants.html#False" title="False"><code class="xref py py-const docutils literal notranslate"><span class="pre">False</span></code></a> instead.
(Contributed by Ethan Furman in <a class="reference external" href="https://bugs.python.org/issue33217">bpo-33217</a>.)</p>
</div>
<div class="section" id="gettext">
<h3>gettext<a class="headerlink" href="#gettext" title="Permalink to this headline">¶</a></h3>
<p>Using non-integer value for selecting a plural form in <a class="reference internal" href="../library/gettext.html#module-gettext" title="gettext: Multilingual internationalization services."><code class="xref py py-mod docutils literal notranslate"><span class="pre">gettext</span></code></a> is
now deprecated.  It never correctly worked. (Contributed by Serhiy Storchaka
in <a class="reference external" href="https://bugs.python.org/issue28692">bpo-28692</a>.)</p>
</div>
<div class="section" id="id6">
<h3>importlib<a class="headerlink" href="#id6" title="Permalink to this headline">¶</a></h3>
<p>Methods
<a class="reference internal" href="../library/importlib.html#importlib.abc.MetaPathFinder.find_module" title="importlib.abc.MetaPathFinder.find_module"><code class="xref py py-meth docutils literal notranslate"><span class="pre">MetaPathFinder.find_module()</span></code></a>
(replaced by
<a class="reference internal" href="../library/importlib.html#importlib.abc.MetaPathFinder.find_spec" title="importlib.abc.MetaPathFinder.find_spec"><code class="xref py py-meth docutils literal notranslate"><span class="pre">MetaPathFinder.find_spec()</span></code></a>)
and
<a class="reference internal" href="../library/importlib.html#importlib.abc.PathEntryFinder.find_loader" title="importlib.abc.PathEntryFinder.find_loader"><code class="xref py py-meth docutils literal notranslate"><span class="pre">PathEntryFinder.find_loader()</span></code></a>
(replaced by
<a class="reference internal" href="../library/importlib.html#importlib.abc.PathEntryFinder.find_spec" title="importlib.abc.PathEntryFinder.find_spec"><code class="xref py py-meth docutils literal notranslate"><span class="pre">PathEntryFinder.find_spec()</span></code></a>)
both deprecated in Python 3.4 now emit <a class="reference internal" href="../library/exceptions.html#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a>.
(Contributed by Matthias Bussonnier in <a class="reference external" href="https://bugs.python.org/issue29576">bpo-29576</a>)</p>
<p>The <a class="reference internal" href="../library/importlib.html#importlib.abc.ResourceLoader" title="importlib.abc.ResourceLoader"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.abc.ResourceLoader</span></code></a> ABC has been deprecated in
favour of <a class="reference internal" href="../library/importlib.html#importlib.abc.ResourceReader" title="importlib.abc.ResourceReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.abc.ResourceReader</span></code></a>.</p>
</div>
<div class="section" id="id7">
<h3>locale<a class="headerlink" href="#id7" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/locale.html#locale.format" title="locale.format"><code class="xref py py-func docutils literal notranslate"><span class="pre">locale.format()</span></code></a> has been deprecated, use <a class="reference internal" href="../library/locale.html#locale.format_string" title="locale.format_string"><code class="xref py py-meth docutils literal notranslate"><span class="pre">locale.format_string()</span></code></a>
instead.  (Contributed by Garvit in <a class="reference external" href="https://bugs.python.org/issue10379">bpo-10379</a>.)</p>
</div>
<div class="section" id="macpath">
<h3>macpath<a class="headerlink" href="#macpath" title="Permalink to this headline">¶</a></h3>
<p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">macpath</span></code> is now deprecated and will be removed in Python 3.8.
(Contributed by Chi Hsuan Yen in <a class="reference external" href="https://bugs.python.org/issue9850">bpo-9850</a>.)</p>
</div>
<div class="section" id="threading">
<h3>threading<a class="headerlink" href="#threading" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/dummy_threading.html#module-dummy_threading" title="dummy_threading: Drop-in replacement for the threading module."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dummy_threading</span></code></a> and <a class="reference internal" href="../library/_dummy_thread.html#module-_dummy_thread" title="_dummy_thread: Drop-in replacement for the _thread module."><code class="xref py py-mod docutils literal notranslate"><span class="pre">_dummy_thread</span></code></a> have been deprecated.  It is
no longer possible to build Python with threading disabled.
Use <a class="reference internal" href="../library/threading.html#module-threading" title="threading: Thread-based parallelism."><code class="xref py py-mod docutils literal notranslate"><span class="pre">threading</span></code></a> instead.
(Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue31370">bpo-31370</a>.)</p>
</div>
<div class="section" id="id8">
<h3>socket<a class="headerlink" href="#id8" title="Permalink to this headline">¶</a></h3>
<p>The silent argument value truncation in <a class="reference internal" href="../library/socket.html#socket.htons" title="socket.htons"><code class="xref py py-func docutils literal notranslate"><span class="pre">socket.htons()</span></code></a> and
<a class="reference internal" href="../library/socket.html#socket.ntohs" title="socket.ntohs"><code class="xref py py-func docutils literal notranslate"><span class="pre">socket.ntohs()</span></code></a> has been deprecated.  In future versions of Python,
if the passed argument is larger than 16 bits, an exception will be raised.
(Contributed by Oren Milman in <a class="reference external" href="https://bugs.python.org/issue28332">bpo-28332</a>.)</p>
</div>
<div class="section" id="id9">
<h3>ssl<a class="headerlink" href="#id9" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/ssl.html#ssl.wrap_socket" title="ssl.wrap_socket"><code class="xref py py-func docutils literal notranslate"><span class="pre">ssl.wrap_socket()</span></code></a> is deprecated.  Use
<a class="reference internal" href="../library/ssl.html#ssl.SSLContext.wrap_socket" title="ssl.SSLContext.wrap_socket"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ssl.SSLContext.wrap_socket()</span></code></a> instead.
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue28124">bpo-28124</a>.)</p>
</div>
<div class="section" id="sunau">
<h3>sunau<a class="headerlink" href="#sunau" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/sunau.html#sunau.openfp" title="sunau.openfp"><code class="xref py py-func docutils literal notranslate"><span class="pre">sunau.openfp()</span></code></a> has been deprecated and will be removed in Python 3.9.
Use <a class="reference internal" href="../library/sunau.html#sunau.open" title="sunau.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">sunau.open()</span></code></a> instead.
(Contributed by Brian Curtin in <a class="reference external" href="https://bugs.python.org/issue31985">bpo-31985</a>.)</p>
</div>
<div class="section" id="id10">
<h3>sys<a class="headerlink" href="#id10" title="Permalink to this headline">¶</a></h3>
<p>Deprecated <code class="xref py py-func docutils literal notranslate"><span class="pre">sys.set_coroutine_wrapper()</span></code> and
<code class="xref py py-func docutils literal notranslate"><span class="pre">sys.get_coroutine_wrapper()</span></code>.</p>
<p>The undocumented <code class="docutils literal notranslate"><span class="pre">sys.callstats()</span></code> function has been deprecated and
will be removed in a future Python version.
(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue28799">bpo-28799</a>.)</p>
</div>
<div class="section" id="wave">
<h3>wave<a class="headerlink" href="#wave" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../library/wave.html#wave.openfp" title="wave.openfp"><code class="xref py py-func docutils literal notranslate"><span class="pre">wave.openfp()</span></code></a> has been deprecated and will be removed in Python 3.9.
Use <a class="reference internal" href="../library/wave.html#wave.open" title="wave.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">wave.open()</span></code></a> instead.
(Contributed by Brian Curtin in <a class="reference external" href="https://bugs.python.org/issue31985">bpo-31985</a>.)</p>
</div>
</div>
<div class="section" id="deprecated-functions-and-types-of-the-c-api">
<h2>Deprecated functions and types of the C API<a class="headerlink" href="#deprecated-functions-and-types-of-the-c-api" title="Permalink to this headline">¶</a></h2>
<p>Function <a class="reference internal" href="../c-api/slice.html#c.PySlice_GetIndicesEx" title="PySlice_GetIndicesEx"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySlice_GetIndicesEx()</span></code></a> is deprecated and replaced with
a macro if <code class="docutils literal notranslate"><span class="pre">Py_LIMITED_API</span></code> is not set or set to a value in the range
between <code class="docutils literal notranslate"><span class="pre">0x03050400</span></code> and <code class="docutils literal notranslate"><span class="pre">0x03060000</span></code> (not inclusive), or is <code class="docutils literal notranslate"><span class="pre">0x03060100</span></code>
or higher.  (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue27867">bpo-27867</a>.)</p>
<p><a class="reference internal" href="../c-api/sys.html#c.PyOS_AfterFork" title="PyOS_AfterFork"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_AfterFork()</span></code></a> has been deprecated.  Use <a class="reference internal" href="../c-api/sys.html#c.PyOS_BeforeFork" title="PyOS_BeforeFork"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_BeforeFork()</span></code></a>,
<a class="reference internal" href="../c-api/sys.html#c.PyOS_AfterFork_Parent" title="PyOS_AfterFork_Parent"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_AfterFork_Parent()</span></code></a> or <a class="reference internal" href="../c-api/sys.html#c.PyOS_AfterFork_Child" title="PyOS_AfterFork_Child"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_AfterFork_Child()</span></code></a> instead.
(Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue16500">bpo-16500</a>.)</p>
</div>
<div class="section" id="platform-support-removals">
<span id="id11"></span><h2>Platform Support Removals<a class="headerlink" href="#platform-support-removals" title="Permalink to this headline">¶</a></h2>
<ul>
<li><p>FreeBSD 9 and older are no longer officially supported.</p></li>
<li><p>For full Unicode support, including within extension modules, *nix platforms
are now expected to provide at least one of <code class="docutils literal notranslate"><span class="pre">C.UTF-8</span></code> (full locale),
<code class="docutils literal notranslate"><span class="pre">C.utf8</span></code> (full locale) or <code class="docutils literal notranslate"><span class="pre">UTF-8</span></code> (<code class="docutils literal notranslate"><span class="pre">LC_CTYPE</span></code>-only locale) as an
alternative to the legacy <code class="docutils literal notranslate"><span class="pre">ASCII</span></code>-based <code class="docutils literal notranslate"><span class="pre">C</span></code> locale.</p></li>
<li><p>OpenSSL 0.9.8 and 1.0.1 are no longer supported, which means building CPython
3.7 with SSL/TLS support on older platforms still using these versions
requires custom build options that link to a more recent version of OpenSSL.</p>
<p>Notably, this issue affects the Debian 8 (aka “jessie”) and Ubuntu 14.04
(aka “Trusty”) LTS Linux distributions, as they still use OpenSSL 1.0.1 by
default.</p>
<p>Debian 9 (“stretch”) and Ubuntu 16.04 (“xenial”), as well as recent releases
of other LTS Linux releases (e.g. RHEL/CentOS 7.5, SLES 12-SP3), use OpenSSL
1.0.2 or later, and remain supported in the default build configuration.</p>
<p>CPython’s own <a class="reference external" href="https://github.com/python/cpython/tree/3.8/.travis.yml">CI configuration file</a> provides an
example of using the SSL
<a class="reference external" href="https://github.com/python/cpython/tree/3.8/Tools/ssl/multissltests.py">compatibility testing infrastructure</a> in
CPython’s test suite to build and link against OpenSSL 1.1.0 rather than an
outdated system provided OpenSSL.</p>
</li>
</ul>
</div>
<div class="section" id="api-and-feature-removals">
<h2>API and Feature Removals<a class="headerlink" href="#api-and-feature-removals" title="Permalink to this headline">¶</a></h2>
<p>The following features and APIs have been removed from Python 3.7:</p>
<ul class="simple">
<li><p>The <code class="docutils literal notranslate"><span class="pre">os.stat_float_times()</span></code> function has been removed. It was introduced in
Python 2.3 for backward compatibility with Python 2.2, and was deprecated
since Python 3.1.</p></li>
<li><p>Unknown escapes consisting of <code class="docutils literal notranslate"><span class="pre">'\'</span></code> and an ASCII letter in replacement
templates for <a class="reference internal" href="../library/re.html#re.sub" title="re.sub"><code class="xref py py-func docutils literal notranslate"><span class="pre">re.sub()</span></code></a> were deprecated in Python 3.5, and will now
cause an error.</p></li>
<li><p>Removed support of the <em>exclude</em> argument in <a class="reference internal" href="../library/tarfile.html#tarfile.TarFile.add" title="tarfile.TarFile.add"><code class="xref py py-meth docutils literal notranslate"><span class="pre">tarfile.TarFile.add()</span></code></a>.
It was deprecated in Python 2.7 and 3.2.  Use the <em>filter</em> argument instead.</p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">splitunc()</span></code> function in the <code class="xref py py-mod docutils literal notranslate"><span class="pre">ntpath</span></code> module was deprecated in
Python 3.1, and has now been removed.  Use the <a class="reference internal" href="../library/os.path.html#os.path.splitdrive" title="os.path.splitdrive"><code class="xref py py-func docutils literal notranslate"><span class="pre">splitdrive()</span></code></a>
function instead.</p></li>
<li><p><a class="reference internal" href="../library/collections.html#collections.namedtuple" title="collections.namedtuple"><code class="xref py py-func docutils literal notranslate"><span class="pre">collections.namedtuple()</span></code></a> no longer supports the <em>verbose</em> parameter
or <code class="docutils literal notranslate"><span class="pre">_source</span></code> attribute which showed the generated source code for the
named tuple class.  This was part of an optimization designed to speed-up
class creation.  (Contributed by Jelle Zijlstra with further improvements
by INADA Naoki, Serhiy Storchaka, and Raymond Hettinger in <a class="reference external" href="https://bugs.python.org/issue28638">bpo-28638</a>.)</p></li>
<li><p>Functions <a class="reference internal" href="../library/functions.html#bool" title="bool"><code class="xref py py-func docutils literal notranslate"><span class="pre">bool()</span></code></a>, <a class="reference internal" href="../library/functions.html#float" title="float"><code class="xref py py-func docutils literal notranslate"><span class="pre">float()</span></code></a>, <a class="reference internal" href="../library/stdtypes.html#list" title="list"><code class="xref py py-func docutils literal notranslate"><span class="pre">list()</span></code></a> and <a class="reference internal" href="../library/stdtypes.html#tuple" title="tuple"><code class="xref py py-func docutils literal notranslate"><span class="pre">tuple()</span></code></a> no
longer take keyword arguments.  The first argument of <a class="reference internal" href="../library/functions.html#int" title="int"><code class="xref py py-func docutils literal notranslate"><span class="pre">int()</span></code></a> can now
be passed only as positional argument.</p></li>
<li><p>Removed previously deprecated in Python 2.4 classes <code class="docutils literal notranslate"><span class="pre">Plist</span></code>, <code class="docutils literal notranslate"><span class="pre">Dict</span></code> and
<code class="docutils literal notranslate"><span class="pre">_InternalDict</span></code> in the <a class="reference internal" href="../library/plistlib.html#module-plistlib" title="plistlib: Generate and parse Mac OS X plist files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">plistlib</span></code></a> module.  Dict values in the result
of functions <a class="reference internal" href="../library/plistlib.html#plistlib.readPlist" title="plistlib.readPlist"><code class="xref py py-func docutils literal notranslate"><span class="pre">readPlist()</span></code></a> and
<a class="reference internal" href="../library/plistlib.html#plistlib.readPlistFromBytes" title="plistlib.readPlistFromBytes"><code class="xref py py-func docutils literal notranslate"><span class="pre">readPlistFromBytes()</span></code></a> are now normal dicts.  You no longer
can use attribute access to access items of these dictionaries.</p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">asyncio.windows_utils.socketpair()</span></code> function has been
removed.  Use the <a class="reference internal" href="../library/socket.html#socket.socketpair" title="socket.socketpair"><code class="xref py py-func docutils literal notranslate"><span class="pre">socket.socketpair()</span></code></a> function instead,
it is available on all platforms since Python 3.5.
<code class="docutils literal notranslate"><span class="pre">asyncio.windows_utils.socketpair</span></code> was just an alias to
<code class="docutils literal notranslate"><span class="pre">socket.socketpair</span></code> on Python 3.5 and newer.</p></li>
<li><p><a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code></a> no longer exports the <a class="reference internal" href="../library/selectors.html#module-selectors" title="selectors: High-level I/O multiplexing."><code class="xref py py-mod docutils literal notranslate"><span class="pre">selectors</span></code></a> and
<code class="xref py py-mod docutils literal notranslate"><span class="pre">_overlapped</span></code> modules as <code class="docutils literal notranslate"><span class="pre">asyncio.selectors</span></code> and
<code class="docutils literal notranslate"><span class="pre">asyncio._overlapped</span></code>. Replace <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">asyncio</span> <span class="pre">import</span> <span class="pre">selectors</span></code> with
<code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">selectors</span></code>.</p></li>
<li><p>Direct instantiation of <a class="reference internal" href="../library/ssl.html#ssl.SSLSocket" title="ssl.SSLSocket"><code class="xref py py-class docutils literal notranslate"><span class="pre">ssl.SSLSocket</span></code></a> and <a class="reference internal" href="../library/ssl.html#ssl.SSLObject" title="ssl.SSLObject"><code class="xref py py-class docutils literal notranslate"><span class="pre">ssl.SSLObject</span></code></a>
objects is now prohibited. The constructors were never documented, tested,
or designed as public constructors.  Users were supposed to use
<a class="reference internal" href="../library/ssl.html#ssl.wrap_socket" title="ssl.wrap_socket"><code class="xref py py-func docutils literal notranslate"><span class="pre">ssl.wrap_socket()</span></code></a> or <a class="reference internal" href="../library/ssl.html#ssl.SSLContext" title="ssl.SSLContext"><code class="xref py py-class docutils literal notranslate"><span class="pre">ssl.SSLContext</span></code></a>.
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue32951">bpo-32951</a>.)</p></li>
<li><p>The unused <a class="reference internal" href="../library/distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a> <code class="docutils literal notranslate"><span class="pre">install_misc</span></code> command has been removed.
(Contributed by Eric N. Vander Weele in <a class="reference external" href="https://bugs.python.org/issue29218">bpo-29218</a>.)</p></li>
</ul>
</div>
<div class="section" id="module-removals">
<h2>Module Removals<a class="headerlink" href="#module-removals" title="Permalink to this headline">¶</a></h2>
<p>The <code class="docutils literal notranslate"><span class="pre">fpectl</span></code> module has been removed.  It was never enabled by
default, never worked correctly on x86-64, and it changed the Python
ABI in ways that caused unexpected breakage of C extensions.
(Contributed by Nathaniel J. Smith in <a class="reference external" href="https://bugs.python.org/issue29137">bpo-29137</a>.)</p>
</div>
<div class="section" id="windows-only-changes">
<h2>Windows-only Changes<a class="headerlink" href="#windows-only-changes" title="Permalink to this headline">¶</a></h2>
<p>The python launcher, (py.exe), can accept 32 &amp; 64 bit specifiers <strong>without</strong>
having to specify a minor version as well. So <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-3-32</span></code> and <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-3-64</span></code>
become valid as well as <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-3.7-32</span></code>, also the -<em>m</em>-64 and -<em>m.n</em>-64 forms
are now accepted to force 64 bit python even if 32 bit would have otherwise
been used. If the specified version is not available py.exe will error exit.
(Contributed by Steve Barnes in <a class="reference external" href="https://bugs.python.org/issue30291">bpo-30291</a>.)</p>
<p>The launcher can be run as <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-0</span></code> to produce a list of the installed pythons,
<em>with default marked with an asterisk</em>. Running <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-0p</span></code> will include the paths.
If py is run with a version specifier that cannot be matched it will also print
the <em>short form</em> list of available specifiers.
(Contributed by Steve Barnes in <a class="reference external" href="https://bugs.python.org/issue30362">bpo-30362</a>.)</p>
</div>
<div class="section" id="porting-to-python-3-7">
<span id="porting-to-python-37"></span><h2>Porting to Python 3.7<a class="headerlink" href="#porting-to-python-3-7" title="Permalink to this headline">¶</a></h2>
<p>This section lists previously described changes and other bugfixes
that may require changes to your code.</p>
<div class="section" id="changes-in-python-behavior">
<h3>Changes in Python Behavior<a class="headerlink" href="#changes-in-python-behavior" title="Permalink to this headline">¶</a></h3>
<ul>
<li><p><a class="reference internal" href="../reference/compound_stmts.html#async"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span></code></a> and <a class="reference internal" href="../reference/expressions.html#await"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">await</span></code></a> names are now reserved keywords.
Code using these names as identifiers will now raise a <a class="reference internal" href="../library/exceptions.html#SyntaxError" title="SyntaxError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SyntaxError</span></code></a>.
(Contributed by Jelle Zijlstra in <a class="reference external" href="https://bugs.python.org/issue30406">bpo-30406</a>.)</p></li>
<li><p><span class="target" id="index-37"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0479"><strong>PEP 479</strong></a> is enabled for all code in Python 3.7, meaning that
<a class="reference internal" href="../library/exceptions.html#StopIteration" title="StopIteration"><code class="xref py py-exc docutils literal notranslate"><span class="pre">StopIteration</span></code></a> exceptions raised directly or indirectly in
coroutines and generators are transformed into <a class="reference internal" href="../library/exceptions.html#RuntimeError" title="RuntimeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code></a>
exceptions.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue32670">bpo-32670</a>.)</p></li>
<li><p><a class="reference internal" href="../reference/datamodel.html#object.__aiter__" title="object.__aiter__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">object.__aiter__()</span></code></a> methods can no longer be declared as
asynchronous.  (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue31709">bpo-31709</a>.)</p></li>
<li><p>Due to an oversight, earlier Python versions erroneously accepted the
following syntax:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">f</span><span class="p">(</span><span class="mi">1</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">1</span><span class="p">],)</span>

<span class="k">class</span> <span class="nc">C</span><span class="p">(</span><span class="mi">1</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">1</span><span class="p">]):</span>
    <span class="k">pass</span>
</pre></div>
</div>
<p>Python 3.7 now correctly raises a <a class="reference internal" href="../library/exceptions.html#SyntaxError" title="SyntaxError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SyntaxError</span></code></a>, as a generator
expression always needs to be directly inside a set of parentheses
and cannot have a comma on either side, and the duplication of the
parentheses can be omitted only on calls.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue32012">bpo-32012</a> and <a class="reference external" href="https://bugs.python.org/issue32023">bpo-32023</a>.)</p>
</li>
<li><p>When using the <a class="reference internal" href="../using/cmdline.html#cmdoption-m"><code class="xref std std-option docutils literal notranslate"><span class="pre">-m</span></code></a> switch, the initial working directory is now added
to <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>, rather than an empty string (which dynamically denoted
the current working directory at the time of each import). Any programs that
are checking for the empty string, or otherwise relying on the previous
behaviour, will need to be updated accordingly (e.g. by also checking for
<code class="docutils literal notranslate"><span class="pre">os.getcwd()</span></code> or <code class="docutils literal notranslate"><span class="pre">os.path.dirname(__main__.__file__)</span></code>, depending on why
the code was checking for the empty string in the first place).</p></li>
</ul>
</div>
<div class="section" id="changes-in-the-python-api">
<h3>Changes in the Python API<a class="headerlink" href="#changes-in-the-python-api" title="Permalink to this headline">¶</a></h3>
<ul>
<li><p><code class="xref py py-meth docutils literal notranslate"><span class="pre">socketserver.ThreadingMixIn.server_close()</span></code> now waits until all
non-daemon threads complete.  Set the new
<code class="xref py py-attr docutils literal notranslate"><span class="pre">socketserver.ThreadingMixIn.block_on_close</span></code> class attribute to
<code class="docutils literal notranslate"><span class="pre">False</span></code> to get the pre-3.7 behaviour.
(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue31233">bpo-31233</a> and <a class="reference external" href="https://bugs.python.org/issue33540">bpo-33540</a>.)</p></li>
<li><p><code class="xref py py-meth docutils literal notranslate"><span class="pre">socketserver.ForkingMixIn.server_close()</span></code> now waits until all
child processes complete. Set the new
<code class="xref py py-attr docutils literal notranslate"><span class="pre">socketserver.ForkingMixIn.block_on_close</span></code> class attribute to <code class="docutils literal notranslate"><span class="pre">False</span></code>
to get the pre-3.7 behaviour.
(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue31151">bpo-31151</a> and <a class="reference external" href="https://bugs.python.org/issue33540">bpo-33540</a>.)</p></li>
<li><p>The <a class="reference internal" href="../library/locale.html#locale.localeconv" title="locale.localeconv"><code class="xref py py-func docutils literal notranslate"><span class="pre">locale.localeconv()</span></code></a> function now temporarily sets the <code class="docutils literal notranslate"><span class="pre">LC_CTYPE</span></code>
locale to the value of <code class="docutils literal notranslate"><span class="pre">LC_NUMERIC</span></code> in some cases.
(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue31900">bpo-31900</a>.)</p></li>
<li><p><a class="reference internal" href="../library/pkgutil.html#pkgutil.walk_packages" title="pkgutil.walk_packages"><code class="xref py py-meth docutils literal notranslate"><span class="pre">pkgutil.walk_packages()</span></code></a> now raises a <a class="reference internal" href="../library/exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> if <em>path</em> is
a string.  Previously an empty list was returned.
(Contributed by Sanyam Khurana in <a class="reference external" href="https://bugs.python.org/issue24744">bpo-24744</a>.)</p></li>
<li><p>A format string argument for <a class="reference internal" href="../library/string.html#string.Formatter.format" title="string.Formatter.format"><code class="xref py py-meth docutils literal notranslate"><span class="pre">string.Formatter.format()</span></code></a>
is now <a class="reference internal" href="../glossary.html#positional-only-parameter"><span class="std std-ref">positional-only</span></a>.
Passing it as a keyword argument was deprecated in Python 3.5. (Contributed
by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue29193">bpo-29193</a>.)</p></li>
<li><p>Attributes <a class="reference internal" href="../library/http.cookies.html#http.cookies.Morsel.key" title="http.cookies.Morsel.key"><code class="xref py py-attr docutils literal notranslate"><span class="pre">key</span></code></a>,
<a class="reference internal" href="../library/http.cookies.html#http.cookies.Morsel.value" title="http.cookies.Morsel.value"><code class="xref py py-attr docutils literal notranslate"><span class="pre">value</span></code></a> and
<a class="reference internal" href="../library/http.cookies.html#http.cookies.Morsel.coded_value" title="http.cookies.Morsel.coded_value"><code class="xref py py-attr docutils literal notranslate"><span class="pre">coded_value</span></code></a> of class
<a class="reference internal" href="../library/http.cookies.html#http.cookies.Morsel" title="http.cookies.Morsel"><code class="xref py py-class docutils literal notranslate"><span class="pre">http.cookies.Morsel</span></code></a> are now read-only.
Assigning to them was deprecated in Python 3.5.
Use the <a class="reference internal" href="../library/http.cookies.html#http.cookies.Morsel.set" title="http.cookies.Morsel.set"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set()</span></code></a> method for setting them.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue29192">bpo-29192</a>.)</p></li>
<li><p>The <em>mode</em> argument of <a class="reference internal" href="../library/os.html#os.makedirs" title="os.makedirs"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.makedirs()</span></code></a> no longer affects the file
permission bits of newly-created intermediate-level directories.
To set their file permission bits you can set the umask before invoking
<code class="docutils literal notranslate"><span class="pre">makedirs()</span></code>.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue19930">bpo-19930</a>.)</p></li>
<li><p>The <a class="reference internal" href="../library/struct.html#struct.Struct.format" title="struct.Struct.format"><code class="xref py py-attr docutils literal notranslate"><span class="pre">struct.Struct.format</span></code></a> type is now <a class="reference internal" href="../library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> instead of
<a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a>. (Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue21071">bpo-21071</a>.)</p></li>
<li><p><a class="reference internal" href="../library/cgi.html#cgi.parse_multipart" title="cgi.parse_multipart"><code class="xref py py-func docutils literal notranslate"><span class="pre">parse_multipart()</span></code></a> now accepts the <em>encoding</em> and <em>errors</em>
arguments and returns the same results as
<code class="xref py py-class docutils literal notranslate"><span class="pre">FieldStorage</span></code>: for non-file fields, the value associated to a key
is a list of strings, not bytes.
(Contributed by Pierre Quentel in <a class="reference external" href="https://bugs.python.org/issue29979">bpo-29979</a>.)</p></li>
<li><p>Due to internal changes in <a class="reference internal" href="../library/socket.html#module-socket" title="socket: Low-level networking interface."><code class="xref py py-mod docutils literal notranslate"><span class="pre">socket</span></code></a>, calling <a class="reference internal" href="../library/socket.html#socket.fromshare" title="socket.fromshare"><code class="xref py py-func docutils literal notranslate"><span class="pre">socket.fromshare()</span></code></a>
on a socket created by <a class="reference internal" href="../library/socket.html#socket.socket.share" title="socket.socket.share"><code class="xref py py-func docutils literal notranslate"><span class="pre">socket.share</span></code></a> in older
Python versions is not supported.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">repr</span></code> for <a class="reference internal" href="../library/exceptions.html#BaseException" title="BaseException"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BaseException</span></code></a> has changed to not include the trailing
comma.  Most exceptions are affected by this change.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue30399">bpo-30399</a>.)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">repr</span></code> for <a class="reference internal" href="../library/datetime.html#datetime.timedelta" title="datetime.timedelta"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.timedelta</span></code></a> has changed to include the keyword
arguments in the output. (Contributed by Utkarsh Upadhyay in <a class="reference external" href="https://bugs.python.org/issue30302">bpo-30302</a>.)</p></li>
<li><p>Because <a class="reference internal" href="../library/shutil.html#shutil.rmtree" title="shutil.rmtree"><code class="xref py py-func docutils literal notranslate"><span class="pre">shutil.rmtree()</span></code></a> is now implemented using the <a class="reference internal" href="../library/os.html#os.scandir" title="os.scandir"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.scandir()</span></code></a>
function, the user specified handler <em>onerror</em> is now called with the first
argument <code class="docutils literal notranslate"><span class="pre">os.scandir</span></code> instead of <code class="docutils literal notranslate"><span class="pre">os.listdir</span></code> when listing the directory
is failed.</p></li>
<li><p>Support for nested sets and set operations in regular expressions as in
<a class="reference external" href="https://unicode.org/reports/tr18/">Unicode Technical Standard #18</a> might be added in the future.  This would
change the syntax.  To facilitate this future change a <a class="reference internal" href="../library/exceptions.html#FutureWarning" title="FutureWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FutureWarning</span></code></a>
will be raised in ambiguous cases for the time being.
That include sets starting with a literal <code class="docutils literal notranslate"><span class="pre">'['</span></code> or containing literal
character sequences <code class="docutils literal notranslate"><span class="pre">'--'</span></code>, <code class="docutils literal notranslate"><span class="pre">'&amp;&amp;'</span></code>, <code class="docutils literal notranslate"><span class="pre">'~~'</span></code>, and <code class="docutils literal notranslate"><span class="pre">'||'</span></code>.  To
avoid a warning, escape them with a backslash.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue30349">bpo-30349</a>.)</p>
</li>
<li><p>The result of splitting a string on a <a class="reference internal" href="../library/re.html#module-re" title="re: Regular expression operations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">regular</span> <span class="pre">expression</span></code></a>
that could match an empty string has been changed.  For example
splitting on <code class="docutils literal notranslate"><span class="pre">r'\s*'</span></code> will now split not only on whitespaces as it
did previously, but also on empty strings before all non-whitespace
characters and just before the end of the string.
The previous behavior can be restored by changing the pattern
to <code class="docutils literal notranslate"><span class="pre">r'\s+'</span></code>.  A <a class="reference internal" href="../library/exceptions.html#FutureWarning" title="FutureWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FutureWarning</span></code></a> was emitted for such patterns since
Python 3.5.</p>
<p>For patterns that match both empty and non-empty strings, the result of
searching for all matches may also be changed in other cases.  For example
in the string <code class="docutils literal notranslate"><span class="pre">'a\n\n'</span></code>, the pattern <code class="docutils literal notranslate"><span class="pre">r'(?m)^\s*?$'</span></code> will not only
match empty strings at positions 2 and 3, but also the string <code class="docutils literal notranslate"><span class="pre">'\n'</span></code> at
positions 2–3.  To match only blank lines, the pattern should be rewritten
as <code class="docutils literal notranslate"><span class="pre">r'(?m)^[^\S\n]*$'</span></code>.</p>
<p><a class="reference internal" href="../library/re.html#re.sub" title="re.sub"><code class="xref py py-func docutils literal notranslate"><span class="pre">re.sub()</span></code></a> now replaces empty matches adjacent to a previous
non-empty match.  For example <code class="docutils literal notranslate"><span class="pre">re.sub('x*',</span> <span class="pre">'-',</span> <span class="pre">'abxd')</span></code> returns now
<code class="docutils literal notranslate"><span class="pre">'-a-b--d-'</span></code> instead of <code class="docutils literal notranslate"><span class="pre">'-a-b-d-'</span></code> (the first minus between ‘b’ and
‘d’ replaces ‘x’, and the second minus replaces an empty string between
‘x’ and ‘d’).</p>
<p>(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue25054">bpo-25054</a> and <a class="reference external" href="https://bugs.python.org/issue32308">bpo-32308</a>.)</p>
</li>
<li><p>Change <a class="reference internal" href="../library/re.html#re.escape" title="re.escape"><code class="xref py py-func docutils literal notranslate"><span class="pre">re.escape()</span></code></a> to only escape regex special characters instead
of escaping all characters other than ASCII letters, numbers, and <code class="docutils literal notranslate"><span class="pre">'_'</span></code>.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue29995">bpo-29995</a>.)</p></li>
<li><p><a class="reference internal" href="../library/tracemalloc.html#tracemalloc.Traceback" title="tracemalloc.Traceback"><code class="xref py py-class docutils literal notranslate"><span class="pre">tracemalloc.Traceback</span></code></a> frames are now sorted from oldest to most
recent to be more consistent with <a class="reference internal" href="../library/traceback.html#module-traceback" title="traceback: Print or retrieve a stack traceback."><code class="xref py py-mod docutils literal notranslate"><span class="pre">traceback</span></code></a>.
(Contributed by Jesse Bakker in <a class="reference external" href="https://bugs.python.org/issue32121">bpo-32121</a>.)</p></li>
<li><p>On OSes that support <a class="reference internal" href="../library/socket.html#socket.SOCK_NONBLOCK" title="socket.SOCK_NONBLOCK"><code class="xref py py-const docutils literal notranslate"><span class="pre">socket.SOCK_NONBLOCK</span></code></a> or
<a class="reference internal" href="../library/socket.html#socket.SOCK_CLOEXEC" title="socket.SOCK_CLOEXEC"><code class="xref py py-const docutils literal notranslate"><span class="pre">socket.SOCK_CLOEXEC</span></code></a> bit flags, the
<a class="reference internal" href="../library/socket.html#socket.socket.type" title="socket.socket.type"><code class="xref py py-attr docutils literal notranslate"><span class="pre">socket.type</span></code></a> no longer has them applied.
Therefore, checks like <code class="docutils literal notranslate"><span class="pre">if</span> <span class="pre">sock.type</span> <span class="pre">==</span> <span class="pre">socket.SOCK_STREAM</span></code>
work as expected on all platforms.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue32331">bpo-32331</a>.)</p></li>
<li><p>On Windows the default for the <em>close_fds</em> argument of
<a class="reference internal" href="../library/subprocess.html#subprocess.Popen" title="subprocess.Popen"><code class="xref py py-class docutils literal notranslate"><span class="pre">subprocess.Popen</span></code></a> was changed from <a class="reference internal" href="../library/constants.html#False" title="False"><code class="xref py py-const docutils literal notranslate"><span class="pre">False</span></code></a> to <a class="reference internal" href="../library/constants.html#True" title="True"><code class="xref py py-const docutils literal notranslate"><span class="pre">True</span></code></a>
when redirecting the standard handles. If you previously depended on handles
being inherited when using <a class="reference internal" href="../library/subprocess.html#subprocess.Popen" title="subprocess.Popen"><code class="xref py py-class docutils literal notranslate"><span class="pre">subprocess.Popen</span></code></a> with standard io
redirection, you will have to pass <code class="docutils literal notranslate"><span class="pre">close_fds=False</span></code> to preserve the
previous behaviour, or use
<a class="reference internal" href="../library/subprocess.html#subprocess.STARTUPINFO.lpAttributeList" title="subprocess.STARTUPINFO.lpAttributeList"><code class="xref py py-attr docutils literal notranslate"><span class="pre">STARTUPINFO.lpAttributeList</span></code></a>.</p></li>
<li><p><a class="reference internal" href="../library/importlib.html#importlib.machinery.PathFinder.invalidate_caches" title="importlib.machinery.PathFinder.invalidate_caches"><code class="xref py py-meth docutils literal notranslate"><span class="pre">importlib.machinery.PathFinder.invalidate_caches()</span></code></a> – which implicitly
affects <a class="reference internal" href="../library/importlib.html#importlib.invalidate_caches" title="importlib.invalidate_caches"><code class="xref py py-func docutils literal notranslate"><span class="pre">importlib.invalidate_caches()</span></code></a> – now deletes entries
in <a class="reference internal" href="../library/sys.html#sys.path_importer_cache" title="sys.path_importer_cache"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path_importer_cache</span></code></a> which are set to <code class="docutils literal notranslate"><span class="pre">None</span></code>.
(Contributed by Brett Cannon in <a class="reference external" href="https://bugs.python.org/issue33169">bpo-33169</a>.)</p></li>
<li><p>In <a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code></a>,
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.sock_recv" title="asyncio.loop.sock_recv"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.sock_recv()</span></code></a>,
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.sock_sendall" title="asyncio.loop.sock_sendall"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.sock_sendall()</span></code></a>,
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.sock_accept" title="asyncio.loop.sock_accept"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.sock_accept()</span></code></a>,
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.getaddrinfo" title="asyncio.loop.getaddrinfo"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.getaddrinfo()</span></code></a>,
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.getnameinfo" title="asyncio.loop.getnameinfo"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.getnameinfo()</span></code></a>
have been changed to be proper coroutine methods to match their
documentation.  Previously, these methods returned <a class="reference internal" href="../library/asyncio-future.html#asyncio.Future" title="asyncio.Future"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.Future</span></code></a>
instances.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue32327">bpo-32327</a>.)</p></li>
<li><p><a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Server.sockets" title="asyncio.Server.sockets"><code class="xref py py-attr docutils literal notranslate"><span class="pre">asyncio.Server.sockets</span></code></a> now returns a copy of the internal list
of server sockets, instead of returning it directly.
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue32662">bpo-32662</a>.)</p></li>
<li><p><a class="reference internal" href="../library/struct.html#struct.Struct.format" title="struct.Struct.format"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Struct.format</span></code></a> is now a <a class="reference internal" href="../library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> instance
instead of a <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> instance.
(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue21071">bpo-21071</a>.)</p></li>
<li><p><a class="reference internal" href="../library/argparse.html#module-argparse" title="argparse: Command-line option and argument parsing library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">argparse</span></code></a> subparsers can now be made mandatory by passing <code class="docutils literal notranslate"><span class="pre">required=True</span></code>
to <a class="reference internal" href="../library/argparse.html#argparse.ArgumentParser.add_subparsers" title="argparse.ArgumentParser.add_subparsers"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ArgumentParser.add_subparsers()</span></code></a>.
(Contributed by Anthony Sottile in <a class="reference external" href="https://bugs.python.org/issue26510">bpo-26510</a>.)</p></li>
<li><p><a class="reference internal" href="../library/ast.html#ast.literal_eval" title="ast.literal_eval"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ast.literal_eval()</span></code></a> is now stricter.  Addition and subtraction of
arbitrary numbers are no longer allowed.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue31778">bpo-31778</a>.)</p></li>
<li><p><a class="reference internal" href="../library/calendar.html#calendar.Calendar.itermonthdates" title="calendar.Calendar.itermonthdates"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Calendar.itermonthdates</span></code></a>
will now consistently raise an exception when a date falls outside of the
<code class="docutils literal notranslate"><span class="pre">0001-01-01</span></code> through <code class="docutils literal notranslate"><span class="pre">9999-12-31</span></code> range.  To support applications that
cannot tolerate such exceptions, the new
<a class="reference internal" href="../library/calendar.html#calendar.Calendar.itermonthdays3" title="calendar.Calendar.itermonthdays3"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Calendar.itermonthdays3</span></code></a> and
<a class="reference internal" href="../library/calendar.html#calendar.Calendar.itermonthdays4" title="calendar.Calendar.itermonthdays4"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Calendar.itermonthdays4</span></code></a> can be used.
The new methods return tuples and are not restricted by the range supported by
<a class="reference internal" href="../library/datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a>.
(Contributed by Alexander Belopolsky in <a class="reference external" href="https://bugs.python.org/issue28292">bpo-28292</a>.)</p></li>
<li><p><a class="reference internal" href="../library/collections.html#collections.ChainMap" title="collections.ChainMap"><code class="xref py py-class docutils literal notranslate"><span class="pre">collections.ChainMap</span></code></a> now preserves the order of the underlying
mappings.  (Contributed by Raymond Hettinger in <a class="reference external" href="https://bugs.python.org/issue32792">bpo-32792</a>.)</p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">submit()</span></code> method of <a class="reference internal" href="../library/concurrent.futures.html#concurrent.futures.ThreadPoolExecutor" title="concurrent.futures.ThreadPoolExecutor"><code class="xref py py-class docutils literal notranslate"><span class="pre">concurrent.futures.ThreadPoolExecutor</span></code></a>
and <a class="reference internal" href="../library/concurrent.futures.html#concurrent.futures.ProcessPoolExecutor" title="concurrent.futures.ProcessPoolExecutor"><code class="xref py py-class docutils literal notranslate"><span class="pre">concurrent.futures.ProcessPoolExecutor</span></code></a> now raises
a <a class="reference internal" href="../library/exceptions.html#RuntimeError" title="RuntimeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code></a> if called during interpreter shutdown.
(Contributed by Mark Nemec in <a class="reference external" href="https://bugs.python.org/issue33097">bpo-33097</a>.)</p></li>
<li><p>The <a class="reference internal" href="../library/configparser.html#configparser.ConfigParser" title="configparser.ConfigParser"><code class="xref py py-class docutils literal notranslate"><span class="pre">configparser.ConfigParser</span></code></a> constructor now uses <code class="docutils literal notranslate"><span class="pre">read_dict()</span></code>
to process the default values, making its behavior consistent with the
rest of the parser.  Non-string keys and values in the defaults
dictionary are now being implicitly converted to strings.
(Contributed by James Tocknell in <a class="reference external" href="https://bugs.python.org/issue23835">bpo-23835</a>.)</p></li>
<li><p>Several undocumented internal imports were removed.
One example is that <code class="docutils literal notranslate"><span class="pre">os.errno</span></code> is no longer available; use <code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">errno</span></code>
directly instead.
Note that such undocumented internal imports may be removed any time without
notice, even in micro version releases.</p></li>
</ul>
</div>
<div class="section" id="changes-in-the-c-api">
<h3>Changes in the C API<a class="headerlink" href="#changes-in-the-c-api" title="Permalink to this headline">¶</a></h3>
<p>The function <a class="reference internal" href="../c-api/slice.html#c.PySlice_GetIndicesEx" title="PySlice_GetIndicesEx"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySlice_GetIndicesEx()</span></code></a> is considered unsafe for
resizable sequences.  If the slice indices are not instances of <a class="reference internal" href="../library/functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>,
but objects that implement the <code class="xref py py-meth docutils literal notranslate"><span class="pre">__index__()</span></code> method, the sequence can be
resized after passing its length to <code class="xref c c-func docutils literal notranslate"><span class="pre">PySlice_GetIndicesEx()</span></code>.  This
can lead to returning indices out of the length of the sequence.  For
avoiding possible problems use new functions <a class="reference internal" href="../c-api/slice.html#c.PySlice_Unpack" title="PySlice_Unpack"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySlice_Unpack()</span></code></a> and
<a class="reference internal" href="../c-api/slice.html#c.PySlice_AdjustIndices" title="PySlice_AdjustIndices"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySlice_AdjustIndices()</span></code></a>.
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue27867">bpo-27867</a>.)</p>
</div>
<div class="section" id="cpython-bytecode-changes">
<h3>CPython bytecode changes<a class="headerlink" href="#cpython-bytecode-changes" title="Permalink to this headline">¶</a></h3>
<p>There are two new opcodes: <a class="reference internal" href="../library/dis.html#opcode-LOAD_METHOD"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">LOAD_METHOD</span></code></a> and <a class="reference internal" href="../library/dis.html#opcode-CALL_METHOD"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">CALL_METHOD</span></code></a>.
(Contributed by Yury Selivanov and INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue26110">bpo-26110</a>.)</p>
<p>The <code class="xref std std-opcode docutils literal notranslate"><span class="pre">STORE_ANNOTATION</span></code> opcode has been removed.
(Contributed by Mark Shannon in <a class="reference external" href="https://bugs.python.org/issue32550">bpo-32550</a>.)</p>
</div>
<div class="section" id="id12">
<h3>Windows-only Changes<a class="headerlink" href="#id12" title="Permalink to this headline">¶</a></h3>
<p>The file used to override <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> is now called
<code class="docutils literal notranslate"><span class="pre">&lt;python-executable&gt;._pth</span></code> instead of <code class="docutils literal notranslate"><span class="pre">'sys.path'</span></code>.
See <a class="reference internal" href="../using/windows.html#finding-modules"><span class="std std-ref">Finding modules</span></a> for more information.
(Contributed by Steve Dower in <a class="reference external" href="https://bugs.python.org/issue28137">bpo-28137</a>.)</p>
</div>
<div class="section" id="id13">
<h3>Other CPython implementation changes<a class="headerlink" href="#id13" title="Permalink to this headline">¶</a></h3>
<p>In preparation for potential future changes to the public CPython runtime
initialization API (see <span class="target" id="index-38"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0432"><strong>PEP 432</strong></a> for an initial, but somewhat outdated,
draft), CPython’s internal startup
and configuration management logic has been significantly refactored. While
these updates are intended to be entirely transparent to both embedding
applications and users of the regular CPython CLI, they’re being mentioned
here as the refactoring changes the internal order of various operations
during interpreter startup, and hence may uncover previously latent defects,
either in embedding applications, or in CPython itself.
(Initially contributed by Nick Coghlan and Eric Snow as part of
<a class="reference external" href="https://bugs.python.org/issue22257">bpo-22257</a>, and further updated by Nick, Eric, and Victor Stinner in a
number of other issues). Some known details affected:</p>
<ul class="simple">
<li><p><a class="reference internal" href="../c-api/sys.html#c.PySys_AddWarnOptionUnicode" title="PySys_AddWarnOptionUnicode"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_AddWarnOptionUnicode()</span></code></a> is not currently usable by embedding
applications due to the requirement to create a Unicode object prior to
calling <cite>Py_Initialize</cite>. Use <a class="reference internal" href="../c-api/sys.html#c.PySys_AddWarnOption" title="PySys_AddWarnOption"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_AddWarnOption()</span></code></a> instead.</p></li>
<li><p>warnings filters added by an embedding application with
<a class="reference internal" href="../c-api/sys.html#c.PySys_AddWarnOption" title="PySys_AddWarnOption"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_AddWarnOption()</span></code></a> should now more consistently take precedence
over the default filters set by the interpreter</p></li>
</ul>
<p>Due to changes in the way the default warnings filters are configured,
setting <a class="reference internal" href="../c-api/init.html#c.Py_BytesWarningFlag" title="Py_BytesWarningFlag"><code class="xref c c-data docutils literal notranslate"><span class="pre">Py_BytesWarningFlag</span></code></a> to a value greater than one is no longer
sufficient to both emit <a class="reference internal" href="../library/exceptions.html#BytesWarning" title="BytesWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BytesWarning</span></code></a> messages and have them converted
to exceptions.  Instead, the flag must be set (to cause the warnings to be
emitted in the first place), and an explicit <code class="docutils literal notranslate"><span class="pre">error::BytesWarning</span></code>
warnings filter added to convert them to exceptions.</p>
<p>Due to a change in the way docstrings are handled by the compiler, the
implicit <code class="docutils literal notranslate"><span class="pre">return</span> <span class="pre">None</span></code> in a function body consisting solely of a docstring
is now marked as occurring on the same line as the docstring, not on the
function’s header line.</p>
<p>The current exception state has been moved from the frame object to the co-routine.
This simplified the interpreter and fixed a couple of obscure bugs caused by
having swap exception state when entering or exiting a generator.
(Contributed by Mark Shannon in <a class="reference external" href="https://bugs.python.org/issue25612">bpo-25612</a>.)</p>
</div>
</div>
<div class="section" id="notable-changes-in-python-3-7-1">
<h2>Notable changes in Python 3.7.1<a class="headerlink" href="#notable-changes-in-python-3-7-1" title="Permalink to this headline">¶</a></h2>
<p>Starting in 3.7.1, <a class="reference internal" href="../c-api/init.html#c.Py_Initialize" title="Py_Initialize"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_Initialize()</span></code></a> now consistently reads and respects
all of the same environment settings as <a class="reference internal" href="../c-api/veryhigh.html#c.Py_Main" title="Py_Main"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_Main()</span></code></a> (in earlier Python
versions, it respected an ill-defined subset of those environment variables,
while in Python 3.7.0 it didn’t read any of them due to <a class="reference external" href="https://bugs.python.org/issue34247">bpo-34247</a>). If
this behavior is unwanted, set <a class="reference internal" href="../c-api/init.html#c.Py_IgnoreEnvironmentFlag" title="Py_IgnoreEnvironmentFlag"><code class="xref c c-data docutils literal notranslate"><span class="pre">Py_IgnoreEnvironmentFlag</span></code></a> to 1 before
calling <a class="reference internal" href="../c-api/init.html#c.Py_Initialize" title="Py_Initialize"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_Initialize()</span></code></a>.</p>
<p>In 3.7.1 the C API for Context Variables
<a class="reference internal" href="../c-api/contextvars.html#contextvarsobjects-pointertype-change"><span class="std std-ref">was updated</span></a> to use
<a class="reference internal" href="../c-api/structures.html#c.PyObject" title="PyObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyObject</span></code></a> pointers.  See also <a class="reference external" href="https://bugs.python.org/issue34762">bpo-34762</a>.</p>
<p>In 3.7.1 the <a class="reference internal" href="../library/tokenize.html#module-tokenize" title="tokenize: Lexical scanner for Python source code."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tokenize</span></code></a> module now implicitly emits a <code class="docutils literal notranslate"><span class="pre">NEWLINE</span></code> token
when provided with input that does not have a trailing new line.  This behavior
now matches what the C tokenizer does internally.
(Contributed by Ammar Askar in <a class="reference external" href="https://bugs.python.org/issue33899">bpo-33899</a>.)</p>
</div>
<div class="section" id="notable-changes-in-python-3-7-2">
<h2>Notable changes in Python 3.7.2<a class="headerlink" href="#notable-changes-in-python-3-7-2" title="Permalink to this headline">¶</a></h2>
<p>In 3.7.2, <a class="reference internal" href="../library/venv.html#module-venv" title="venv: Creation of virtual environments."><code class="xref py py-mod docutils literal notranslate"><span class="pre">venv</span></code></a> on Windows no longer copies the original binaries, but
creates redirector scripts named <code class="docutils literal notranslate"><span class="pre">python.exe</span></code> and <code class="docutils literal notranslate"><span class="pre">pythonw.exe</span></code> instead.
This resolves a long standing issue where all virtual environments would have
to be upgraded or recreated with each Python update. However, note that this
release will still require recreation of virtual environments in order to get
the new scripts.</p>
</div>
<div class="section" id="notable-changes-in-python-3-7-6">
<h2>Notable changes in Python 3.7.6<a class="headerlink" href="#notable-changes-in-python-3-7-6" title="Permalink to this headline">¶</a></h2>
<p>Due to significant security concerns, the <em>reuse_address</em> parameter of
<a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.create_datagram_endpoint" title="asyncio.loop.create_datagram_endpoint"><code class="xref py py-meth docutils literal notranslate"><span class="pre">asyncio.loop.create_datagram_endpoint()</span></code></a> is no longer supported. This is
because of the behavior of the socket option <code class="docutils literal notranslate"><span class="pre">SO_REUSEADDR</span></code> in UDP. For more
details, see the documentation for <code class="docutils literal notranslate"><span class="pre">loop.create_datagram_endpoint()</span></code>.
(Contributed by Kyle Stanley, Antoine Pitrou, and Yury Selivanov in
<a class="reference external" href="https://bugs.python.org/issue37228">bpo-37228</a>.)</p>
</div>
<div class="section" id="notable-changes-in-python-3-7-10">
<h2>Notable changes in Python 3.7.10<a class="headerlink" href="#notable-changes-in-python-3-7-10" title="Permalink to this headline">¶</a></h2>
<p>Earlier Python versions allowed using both <code class="docutils literal notranslate"><span class="pre">;</span></code> and <code class="docutils literal notranslate"><span class="pre">&amp;</span></code> as
query parameter separators in <a class="reference internal" href="../library/urllib.parse.html#urllib.parse.parse_qs" title="urllib.parse.parse_qs"><code class="xref py py-func docutils literal notranslate"><span class="pre">urllib.parse.parse_qs()</span></code></a> and
<a class="reference internal" href="../library/urllib.parse.html#urllib.parse.parse_qsl" title="urllib.parse.parse_qsl"><code class="xref py py-func docutils literal notranslate"><span class="pre">urllib.parse.parse_qsl()</span></code></a>.  Due to security concerns, and to conform with
newer W3C recommendations, this has been changed to allow only a single
separator key, with <code class="docutils literal notranslate"><span class="pre">&amp;</span></code> as the default.  This change also affects
<a class="reference internal" href="../library/cgi.html#cgi.parse" title="cgi.parse"><code class="xref py py-func docutils literal notranslate"><span class="pre">cgi.parse()</span></code></a> and <a class="reference internal" href="../library/cgi.html#cgi.parse_multipart" title="cgi.parse_multipart"><code class="xref py py-func docutils literal notranslate"><span class="pre">cgi.parse_multipart()</span></code></a> as they use the affected
functions internally. For more details, please see their respective
documentation.
(Contributed by Adam Goldschmidt, Senthil Kumaran and Ken Jin in <a class="reference external" href="https://bugs.python.org/issue42967">bpo-42967</a>.)</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">What’s New In Python 3.7</a><ul>
<li><a class="reference internal" href="#summary-release-highlights">Summary – Release Highlights</a></li>
<li><a class="reference internal" href="#new-features">New Features</a><ul>
<li><a class="reference internal" href="#pep-563-postponed-evaluation-of-annotations">PEP 563: Postponed Evaluation of Annotations</a></li>
<li><a class="reference internal" href="#pep-538-legacy-c-locale-coercion">PEP 538: Legacy C Locale Coercion</a></li>
<li><a class="reference internal" href="#pep-540-forced-utf-8-runtime-mode">PEP 540: Forced UTF-8 Runtime Mode</a></li>
<li><a class="reference internal" href="#pep-553-built-in-breakpoint">PEP 553: Built-in <code class="docutils literal notranslate"><span class="pre">breakpoint()</span></code></a></li>
<li><a class="reference internal" href="#pep-539-new-c-api-for-thread-local-storage">PEP 539: New C API for Thread-Local Storage</a></li>
<li><a class="reference internal" href="#pep-562-customization-of-access-to-module-attributes">PEP 562: Customization of Access to Module Attributes</a></li>
<li><a class="reference internal" href="#pep-564-new-time-functions-with-nanosecond-resolution">PEP 564: New Time Functions With Nanosecond Resolution</a></li>
<li><a class="reference internal" href="#pep-565-show-deprecationwarning-in-main">PEP 565: Show DeprecationWarning in <code class="docutils literal notranslate"><span class="pre">__main__</span></code></a></li>
<li><a class="reference internal" href="#pep-560-core-support-for-typing-module-and-generic-types">PEP 560: Core Support for <code class="docutils literal notranslate"><span class="pre">typing</span></code> module and Generic Types</a></li>
<li><a class="reference internal" href="#pep-552-hash-based-pyc-files">PEP 552: Hash-based .pyc Files</a></li>
<li><a class="reference internal" href="#pep-545-python-documentation-translations">PEP 545: Python Documentation Translations</a></li>
<li><a class="reference internal" href="#development-runtime-mode-x-dev">Development Runtime Mode: -X dev</a></li>
</ul>
</li>
<li><a class="reference internal" href="#other-language-changes">Other Language Changes</a></li>
<li><a class="reference internal" href="#new-modules">New Modules</a><ul>
<li><a class="reference internal" href="#contextvars">contextvars</a></li>
<li><a class="reference internal" href="#dataclasses">dataclasses</a></li>
<li><a class="reference internal" href="#importlib-resources">importlib.resources</a></li>
</ul>
</li>
<li><a class="reference internal" href="#improved-modules">Improved Modules</a><ul>
<li><a class="reference internal" href="#argparse">argparse</a></li>
<li><a class="reference internal" href="#asyncio">asyncio</a></li>
<li><a class="reference internal" href="#binascii">binascii</a></li>
<li><a class="reference internal" href="#calendar">calendar</a></li>
<li><a class="reference internal" href="#collections">collections</a></li>
<li><a class="reference internal" href="#compileall">compileall</a></li>
<li><a class="reference internal" href="#concurrent-futures">concurrent.futures</a></li>
<li><a class="reference internal" href="#contextlib">contextlib</a></li>
<li><a class="reference internal" href="#cprofile">cProfile</a></li>
<li><a class="reference internal" href="#crypt">crypt</a></li>
<li><a class="reference internal" href="#datetime">datetime</a></li>
<li><a class="reference internal" href="#dbm">dbm</a></li>
<li><a class="reference internal" href="#decimal">decimal</a></li>
<li><a class="reference internal" href="#dis">dis</a></li>
<li><a class="reference internal" href="#distutils">distutils</a></li>
<li><a class="reference internal" href="#enum">enum</a></li>
<li><a class="reference internal" href="#functools">functools</a></li>
<li><a class="reference internal" href="#gc">gc</a></li>
<li><a class="reference internal" href="#hmac">hmac</a></li>
<li><a class="reference internal" href="#http-client">http.client</a></li>
<li><a class="reference internal" href="#http-server">http.server</a></li>
<li><a class="reference internal" href="#idlelib-and-idle">idlelib and IDLE</a></li>
<li><a class="reference internal" href="#importlib">importlib</a></li>
<li><a class="reference internal" href="#io">io</a></li>
<li><a class="reference internal" href="#ipaddress">ipaddress</a></li>
<li><a class="reference internal" href="#itertools">itertools</a></li>
<li><a class="reference internal" href="#locale">locale</a></li>
<li><a class="reference internal" href="#logging">logging</a></li>
<li><a class="reference internal" href="#math">math</a></li>
<li><a class="reference internal" href="#mimetypes">mimetypes</a></li>
<li><a class="reference internal" href="#msilib">msilib</a></li>
<li><a class="reference internal" href="#multiprocessing">multiprocessing</a></li>
<li><a class="reference internal" href="#os">os</a></li>
<li><a class="reference internal" href="#pathlib">pathlib</a></li>
<li><a class="reference internal" href="#pdb">pdb</a></li>
<li><a class="reference internal" href="#py-compile">py_compile</a></li>
<li><a class="reference internal" href="#pydoc">pydoc</a></li>
<li><a class="reference internal" href="#queue">queue</a></li>
<li><a class="reference internal" href="#re">re</a></li>
<li><a class="reference internal" href="#signal">signal</a></li>
<li><a class="reference internal" href="#socket">socket</a></li>
<li><a class="reference internal" href="#socketserver">socketserver</a></li>
<li><a class="reference internal" href="#sqlite3">sqlite3</a></li>
<li><a class="reference internal" href="#ssl">ssl</a></li>
<li><a class="reference internal" href="#string">string</a></li>
<li><a class="reference internal" href="#subprocess">subprocess</a></li>
<li><a class="reference internal" href="#sys">sys</a></li>
<li><a class="reference internal" href="#time">time</a></li>
<li><a class="reference internal" href="#tkinter">tkinter</a></li>
<li><a class="reference internal" href="#tracemalloc">tracemalloc</a></li>
<li><a class="reference internal" href="#types">types</a></li>
<li><a class="reference internal" href="#unicodedata">unicodedata</a></li>
<li><a class="reference internal" href="#unittest">unittest</a></li>
<li><a class="reference internal" href="#unittest-mock">unittest.mock</a></li>
<li><a class="reference internal" href="#urllib-parse">urllib.parse</a></li>
<li><a class="reference internal" href="#uu">uu</a></li>
<li><a class="reference internal" href="#uuid">uuid</a></li>
<li><a class="reference internal" href="#warnings">warnings</a></li>
<li><a class="reference internal" href="#xml-etree">xml.etree</a></li>
<li><a class="reference internal" href="#xmlrpc-server">xmlrpc.server</a></li>
<li><a class="reference internal" href="#zipapp">zipapp</a></li>
<li><a class="reference internal" href="#zipfile">zipfile</a></li>
</ul>
</li>
<li><a class="reference internal" href="#c-api-changes">C API Changes</a></li>
<li><a class="reference internal" href="#build-changes">Build Changes</a></li>
<li><a class="reference internal" href="#optimizations">Optimizations</a></li>
<li><a class="reference internal" href="#other-cpython-implementation-changes">Other CPython Implementation Changes</a></li>
<li><a class="reference internal" href="#deprecated-python-behavior">Deprecated Python Behavior</a></li>
<li><a class="reference internal" href="#deprecated-python-modules-functions-and-methods">Deprecated Python modules, functions and methods</a><ul>
<li><a class="reference internal" href="#aifc">aifc</a></li>
<li><a class="reference internal" href="#whatsnew37-asyncio-deprecated">asyncio</a></li>
<li><a class="reference internal" href="#id3">collections</a></li>
<li><a class="reference internal" href="#id4">dbm</a></li>
<li><a class="reference internal" href="#id5">enum</a></li>
<li><a class="reference internal" href="#gettext">gettext</a></li>
<li><a class="reference internal" href="#id6">importlib</a></li>
<li><a class="reference internal" href="#id7">locale</a></li>
<li><a class="reference internal" href="#macpath">macpath</a></li>
<li><a class="reference internal" href="#threading">threading</a></li>
<li><a class="reference internal" href="#id8">socket</a></li>
<li><a class="reference internal" href="#id9">ssl</a></li>
<li><a class="reference internal" href="#sunau">sunau</a></li>
<li><a class="reference internal" href="#id10">sys</a></li>
<li><a class="reference internal" href="#wave">wave</a></li>
</ul>
</li>
<li><a class="reference internal" href="#deprecated-functions-and-types-of-the-c-api">Deprecated functions and types of the C API</a></li>
<li><a class="reference internal" href="#platform-support-removals">Platform Support Removals</a></li>
<li><a class="reference internal" href="#api-and-feature-removals">API and Feature Removals</a></li>
<li><a class="reference internal" href="#module-removals">Module Removals</a></li>
<li><a class="reference internal" href="#windows-only-changes">Windows-only Changes</a></li>
<li><a class="reference internal" href="#porting-to-python-3-7">Porting to Python 3.7</a><ul>
<li><a class="reference internal" href="#changes-in-python-behavior">Changes in Python Behavior</a></li>
<li><a class="reference internal" href="#changes-in-the-python-api">Changes in the Python API</a></li>
<li><a class="reference internal" href="#changes-in-the-c-api">Changes in the C API</a></li>
<li><a class="reference internal" href="#cpython-bytecode-changes">CPython bytecode changes</a></li>
<li><a class="reference internal" href="#id12">Windows-only Changes</a></li>
<li><a class="reference internal" href="#id13">Other CPython implementation changes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#notable-changes-in-python-3-7-1">Notable changes in Python 3.7.1</a></li>
<li><a class="reference internal" href="#notable-changes-in-python-3-7-2">Notable changes in Python 3.7.2</a></li>
<li><a class="reference internal" href="#notable-changes-in-python-3-7-6">Notable changes in Python 3.7.6</a></li>
<li><a class="reference internal" href="#notable-changes-in-python-3-7-10">Notable changes in Python 3.7.10</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="3.8.html"
                        title="previous chapter">What’s New In Python 3.8</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="3.6.html"
                        title="next chapter">What’s New In Python 3.6</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">Report a Bug</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/3.8/Doc/whatsnew/3.7.rst"
            rel="nofollow">Show Source
        </a>
      </li>
    </ul>
  </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="3.6.html" title="What’s New In Python 3.6"
             >next</a> |</li>
        <li class="right" >
          <a href="3.8.html" title="What’s New In Python 3.8"
             >previous</a> |</li>

          <li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
          <li><a href="https://www.python.org/">Python</a> &#187;</li>
          <li class="switchers">
            <div class="language_switcher_placeholder"></div>
            <div class="version_switcher_placeholder"></div>
          </li>
          <li>
              
          </li>
    <li id="cpython-language-and-version">
      <a href="../index.html">3.8.13 Documentation</a> &#187;
    </li>

          <li class="nav-item nav-item-1"><a href="index.html" >What’s New in Python</a> &#187;</li>
                <li class="right">
                    

    <div class="inline-search" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" aria-label="Quick search" type="text" name="q" />
          <input type="submit" value="Go" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
                     |
                </li>
            
      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 2001-2022, Python Software Foundation.
    <br />
    This page is licensed under the Python Software Foundation License Version 2.
    <br />
    Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
    <br />
    
    <br />

    The Python Software Foundation is a non-profit corporation.
<a href="https://www.python.org/psf/donations/">Please donate.</a>
<br />
    <br />

    Last updated on Mar 17, 2022.
    <a href="https://docs.python.org/3/bugs.html">Found a bug</a>?
    <br />

    Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 2.4.4.
    </div>

  </body>
</html>